Task
You will write a class called Grid, and test it with a couple of programs. A Grid object will be made up of a grid of positions, numbered with rows and columns. Row and column numbering start at 0, at the top left corner of the grid. A grid object also has a "mover", which can move around to different locations on the grid. Obstacles (which block the mover) and other objects (that can be placed or picked up) are also available. Here is a sample picture of a Grid object in its display format:
0 . . . This is a Grid object with 4 rows and 4 columns (numbered 0 - 3). . . > . The mover '>' is at row 1, column 2, facing east. . . . . The obstacle '#' is at row 3, column 1 . # . . The other item '0' is at row 0, column 0
The @ character indicates that the mover and an item (0) currently occupy the same position on the grid.
Program Details and Requirements
1) Grid class
Download this starter file: grid_starter.h and rename it as grid.h. Your member function prototypes are already given in this file. You will need to add appropriate member data. You will also need to define each of the member functions in the file grid.cpp. You may add whatever member data you need, but you must store the grid itself as a two-dimensional array. Maximum grid size will be 40 rows and 40 columns. (Note that this means dynamic allocation will NOT be needed for this assignment).
Meaning of Grid symbols
. empty spot on the grid 0 an item that can be placed, or picked up # a block (an obstacle). Mover cannot move through it < mover facing WEST > mover facing EAST ^ mover facing NORTH v mover facing SOUTH @ mover occupying same place as item (0)
A printed space ' ' in a grid position represents a spot that the mover has already moved through when the path display is toggled on
public Member function descriptions
You'll need the library cstdlib for the srand and rand functions. While it's not normally the best place to do it, you can go ahead and seed the random number generator here in the constructor in some appropriate way so that it's different for seperate program runs.
If you need a refresher on pseudo-random number generation, see this notes set from COP 3014: http://www.cs.fsu.edu/~myers/c++/notes/rand.html
2) Test Program
Trapped!
Write a main program in a file called trap.cpp that solves the following scenario, using your Grid class:
Giant Mole People have risen from their underground lairs and are taking over the world. You have been taken prisoner and placed in an underground jail cell. Since the Mole People are blind and don't know how to build doors, your cell has one open exit (no door). Since you are deep underground, it is completely dark and you cannot see. Your task is to escape your prison to join the human resistance!
Your program should ask the user to input the number of rows, then columns, for the grid. (Note that this is the ONLY keyboard input for this program). Create a grid with the specified number of rows and columns, using the constructor with two parameters -- (this is the one that should automatically create a fenced-in grid containing one exit and a randomly placed mover). Display the initial grid. Since the placement of the exit and the mover is random, execution of this program will look a little different every time. Your task is to escape the trap! You will need to create an algorithm that will instruct the mover to find its way to the exit. (Hint: Think about how to use the Predicate functions before you move). Upon reaching the exit, you should print a message of success, like "We escaped!", and then output the final position of the mover. Keep the path toggled ON. You only need to display the initial setup grid and the final grid for this program.
General Requirements:
Submit the following files through the web page in the usual manner:
grid.h grid.cpp trap.cpp
// ---------------------------------------
// header file grid.h
// Grid class class Grid { public: // public static class constants, for direction indicators static const int NORTH = 0; static const int WEST = 1; static const int SOUTH = 2; static const int EAST = 3; // public member funcitons Grid(); // build 1 x 1 grid with mover in only // square, facing east Grid(int r, int c); // build grid with r rows, c cols, // blocks around edge with random exit // and random mover position and direction Grid(int r, int c, int mr, int mc, int d); // build empty grid with r rows, c cols, and mover // at row mr, col mc, and facing direction d bool Move(int s); // move forward s spaces, if possible void TogglePath(); // toggle whether or not moved path is shown void TurnLeft(); // turn the mover to the left void PutDown(); // put down an item at the mover's position bool PutDown(int r, int c); // put down an item at (r,c), if possible bool PickUp(); // pick up item at current position bool PlaceBlock(int r, int c); // put a block at (r,c), if possible void Grow(int gr, int gc); // grow the grid by gr rows, gc columns void Display() const; // display the grid on screen // Accessors bool FrontIsClear() const; // check to see if space in front of // mover is clear bool RightIsClear() const; // check to see if space to right of // mover is clear int GetRow() const; // return row of the mover int GetCol() const; // return column of the mover int GetNumRows() const; // return number of rows in the grid int GetNumCols() const; // return number of columns in the grid private: };
In: Computer Science
Artificial Intelligence Question. This topic is about AI representation stochastic methods. I will like it if this is good explained and answer
Represent the robot arm problem from earlier sections as a production system. For simplicity use the basic representation that doesn’t care exactly where the blocks are, just if they’re stacked or not. It will only be given four blocks a, b, c, d in some configuration and have to move them until a goal configuration is reached.
In: Computer Science
JAVA CODE BEGINNERS, I already have the demo code included
Write a Bottle class. The Bottle will have one private int that represents the countable value in the Bottle. Please use one of these names: cookies, marbles, M&Ms, pennies, nickels, dimes or pebbles. The class has these 14 methods: read()(please use a while loop to prompt for an acceptable value), set(int), set(Bottle), get(), (returns the value stored in Bottle), add(Bottle), subtract(Bottle), multiply(Bottle), divide(Bottle), add(int), subtract(int), multiply(int), divide(int), equals(Bottle), and toString()(toString() method will be given in class). All add, subtract, multiply and divide methods return a Bottle. This means the demo code b2 = b3.add(b1) brings into the add method a Bottle b1 which is added to b3. Bottle b3 is the this Bottle. The returned bottle is a new bottle containing the sum of b1 and b3. The value of b3 (the this bottle) is not changed. Your Bottle class must guarantee bottles always have a positive value and never exceed a maximum number chosen by you. These numbers are declared as constants of the class. Use the names MIN and MAX. The read() method should guarantee a value that does not violate the MIN or MAX value. Use a while loop in the read method to prompt for a new value if necessary. Each method with a parameter must be examined to determine if the upper or lower bound could be violated. In the case of the add method with a Bottle parameter your code must test for violating the maximum value. It is impossible for this add method to violate the minimum value of zero. The method subtract with a Bottle parameter must test for a violation of the minimum zero value but should not test for exceeding the maximum value. In the case of a parameter that is an integer, all methods must be examined to guarantee a value that does not violate the MIN or MAX values. Consider each method carefully and test only the conditions that could be violated.
import java.util.Scanner; // test driver for the Bottle class public class BottleDemo3 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int x; Bottle bottle1 = new Bottle(); Bottle bottle2 = new Bottle(); Bottle bottle3 = new Bottle(); Bottle bottle4 = new Bottle(); Bottle bottle5 = new Bottle(); System.out.println("please enter a number for bottle1:"); bottle1.read(); System.out.println("Bottle1 is this value " + bottle1 + "."); System.out.println("Please enter a number for bottle2:"); bottle2.read(); bottle3 = bottle2.add(bottle1); System.out.println("The sum of bottle2 and bottle1 is: " + bottle3 + "."); bottle4 = bottle3.divide(2); System.out.println("The 2 bottle average is: " + bottle4 + "."); System.out.print("Subtracting bottle1 from bottle2 is: " ); bottle3 = bottle2.subtract(bottle1); System.out.println( bottle3); bottle3 = bottle2.divide(bottle1); System.out.println("Dividing bottle2 with bottle1 is: " + bottle3 + "."); if (bottle1.equals(bottle2)) { System.out.println("Bottle1 and bottle2 are equal."); } else { System.out.println("Bottle1 and bottle2 are not equal."); } System.out.println("Bottle4 is now given the value of 10 with the set() method."); bottle4.set(10); System.out.println("The value of bottle4 is " + bottle4 + "."); System.out.println("Bottle4 is now multipled with bottle1. The value is placed in " + "bottle5."); bottle5 = bottle1.multiply(bottle4); System.out.println("The value of bottle5 is " + bottle5 + "."); System.out.println("Enter an integer to add to the value bottle1 has."); System.out.println("The sum will be put in bottle3."); x = scan.nextInt(); bottle3 = bottle1.add(x); System.out.println("Adding your number " + x + " to bottle1 gives a new Bottle with " + bottle3 + " in it."); System.out.print("Adding the number " + bottle2 + " which is the number" + " in bottle2 to the\nnumber in "); bottle2 = bottle1.add(bottle2); System.out.println("bottle1 which is " + bottle1 +" gives " + bottle2 + "."); bottle2.set(bottle2.get()); } }
In: Computer Science
briefly describe the characteristics of Sermo and Doximity as social media platforms with respect to; platform type, user population, scope of medicine and health problems, and member interaction style.
In: Computer Science
C++ Coding Exercise (If... Else)
Hello All, I know this question has been asked before, but I was unable to run any of the programs that were posted and I'm stuck. I would like to see an explanation with the code and exactly how to add a .txt file to the program through VS 2019, if possible.
LAB:
Write a C++ program that computes a student’s grade for an assignment as a percentage given the student’s score and total points. The final score must be rounded up to the nearest whole value using the ceil function in the header file. You must also display the floating-point result up to 5 decimal places. The input to the program must come from a file containing a single line with the score and total separated by a space.
In addition, you must print to the console “Excellent” if the grade is greater than or equal to 90, “Well Done” if the grade is less than 90 and greater than or equal to 80, “Good” if the grade is less than 80 and greater than or equal to 70, “Need Improvement” if the grade is less than 70 and greater than or equal to 60, and “Fail” if the grade is less than 60.
In: Computer Science
Python Programming
This assignment will give you practice with
interactive programs, if/else statements, collections, loops and
functions.
Problem Description
A small car yard dealing in second hand cars needs an application
to keep records of cars in stock. Details of each car shall include
registration(rego), model, color, price paid for the car (i.e.
purchase price) and selling price. Selling price is calculated as
purchased price plus mark-up of 30%. For example, Toyota Corolla
bought for $20,000 will have the selling price of 20000 * (1 + 0.3)
= 26000.
Task Requirements
Imagine you have been invited to develop a menu driven python
application to manage records of cars in stock. Based on the
problem description, starter program (code template) has been
provided. Investigate the provided starter program. There are four
scripts(application.py, caryard.py, cars.py and vehicle.py). Driver
function(main) is defined in the appliction.py, which imports
caryard module(caryard.py). Caryard declares all the core functions
(buy, sell, search, etc. …) for supporting the car yard business.
The caryard module imports cars module(cars.py), and the cars
module in turn imports the vehicle that include a definition of a
Car class.
Program is executed by loading and running the application.py. The
important work of interconnecting and wiring of modules and
functions have been already been done. However, most of these
functions, although declared and wired up in the program are not
yet implemented. Your task is to implement these functions. There
are eleven (11) tasks to be completed described next within the
modules:
1. application.py
• Task 1: implement menu ()
2. caryard.py
• Task 2: implement buy_car ()
• Task 3: implement sell_car ()
• Task 4: implement search_car ()
• Task 5: implement list_all_cars ()
3. cars.py
• Task 6: implement addCar (rego, model, color, price)
• Task 7: implement removeCar (rego)
• Task 8: implement all_cars ()
• Task 9: implement search(rego)
4. vehicle.py
• Task 10: implement the Car class
• Task 11: UML model of a Car class
Description of Program functions:
Program displays a menu on execution. Five menu options are
available to allow the user to buy, sell, search, show all cars,
and exit program respectively. Program functionality and screen
output for each of the menu option when selected by the user
follows:
Program menu on execution:
Option 1 (Buy a car): User enters 1. Note the error message for
duplicate car rego
Option 2 (Sell a car): User enters 2. Note the error message for
invalid car rego, and the sell price which is a (30%) mark-up of
purchase price.
Option 3 (Search): User enters 3
Option 4 (Show all): User enters 4
Option 5 (Exit Program): User enters 5
In: Computer Science
Course : Physical Security
Submit a paper on the weaknesses of biometric authentication
Assignment is worth 50 points and 10% of your grade
In: Computer Science
SQL Server
6. Our new system cannot handle Unicode (Links to an external
site.) characters, only ASCII (Links to an external site.)
characters.
The current Productname data type is NVARCHAR, which is unicode,
and might have non-ASCII characters in it. We need to check!
Show the ProductID, and ProductName, and the first location of any
non-Unicode characters. See the note at the bottom for how to find
non-Unicode characters.
In: Computer Science
In: Computer Science
C++ contains some built-in functions (such as itoa and std::hex) which make this assignment trivial. You may NOT use these in your programs. You code must perform the conversion through your own algorithm.
The input values are:
5
9
24
2
39
83
60
8
11
10
6
18
31
27
In: Computer Science
(Minimum 100 words)
1. What are the two different transmission modes? Explain?
2.Define a DC component and its effect on digital transmission.
3. Distinguish between a signal element and a data element
In: Computer Science
Using Python read dataset in the HTML in beautiful way.
You need to read CSV file ( Use any for example, You
can use small dataset)
You need to use pandas library
You need to use Flask
Make search table like YouTube has.
In: Computer Science
In: Computer Science
Design and implement a special purpose system that allows access to doors 1 and 2 (D1 and D2 respectively) by persons who have been given a valid four-bit binary code. The code is entered using four switches: S1, S2, S3, and S4. Each valid switch can be set to 0 or 1. The system gives access to doors according to the following scheme:
Provide a truth table and implement your circuit only using NOR gates. The correct implementation of this circuit should only have two layers of NOR gates.
In: Computer Science
Design a kernel module that creates a /proc file named /proc/jiffies that reports the current value of jiffies when the /proc/jiffies file is read, such as with the command
cat /proc/jiffies
Be sure to remove /proc/jiffies when the module is removed.
Please help with this assignment using C programming and testing in Linux Ubuntu.
In: Computer Science