Question: v using C++ The student is to create a small game that simulates the control of the Mars Rover. Sample sessions of an actual such

v using C++ The student is to create a small game thatvsimulates the control of the Mars Rover. Sample sessions of an actualsuch basic program is provided for your reference in the Figure inthe next section of this document. Take note that the program generates using C++

The student is to create a small game that simulates the control of the Mars Rover. Sample sessions of an actual such basic program is provided for your reference in the Figure in the next section of this document. Take note that the program generates everything on the display. Those parts that required user's response (after the "=>" symbol) are to be typed by the user. TCP1101 Programming Fundamentals Assignment #2 Trimester 2, 2020/21 Take note that this is only the minimal basic requirement; you should add as much features as possible to your program and to make it as user-friendly as possible in order to get better marks. Recommendation on how to develop the program: a. Create a class named Map which would be used to create the following: The actual Map of Mars, which is to be hidden from the user and will only be displayed to the user at the end of the game. The Mars Rover Mapper, which keeps track of the cells in the map the Rover had already observed. b. One possible minimal class declaration for Map is shown below: class Map { private: vector > map; int dimx, dimY; public: Map (int dimx, int dimy); void resize (int dimx, int dimy, char ch); void display(); void setObject(int n, int y, char ch); char getObject (int x, int y); bool isEmpty (int x, int y); bool isHill(int x, int y); bool isTrap (int x, int y); bool isInsideMap (int x, int y); int getDimx(); int getDimy(); }; //Map c. Create a class named Rover, which would be used to keep track of the location and heading of the Rover. One possible minimal class declaration is shown below. class Rover { private: int x,y; Direction heading; char object UnderRover; Map* p_mars; I/a pointer to the map for Mars Map mapper; l/a map that keeps track of observed cells so far public: Rover(); void land (Map& mars); //links a map of Mars to a Rover bool turn Left(); bool turnRight(); bool move(); void displayMapper(); bool executeCommand (char command); }; //Rover d. The class declarations above are only the bare minimal, you may want to add member d. The class declarations above are only the bare minimal, you may want to add member functions and data member such as for keeping track of golds collected etc. TCP1101 Programming Fundamentals Assignment #2 Trimester 2, 2020/21 e. The data type Direction can be defined using enumeration as shown below. Please refer to your textbook on how to use enum. enum Direction { north = 0, east = 1, south = 2, west = 3 }; f. As the Rover moves across the map, it would be able to read the three cells just in front of it. g. There are hills on the map which prevent the Rover from moving to those cells. h. There are traps on the map, if the Rover moves to any of those cells, the mission is failed. i. You are free to design your scoring system and other type of cells, you may also introduce new challenges for the Rover. Sample Session of a Demo Program is shown below. Let's explore Mars... Mars dimension X => 15 Mars dimension Y => 5 No of Golds => 4 - Mars Rover Mapper +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 51?|?|?|?|?|?|?|?|?|?|?|?|?|?|?| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 41?|?|?|?|?|?|?|?| ?|?|?|?|?|?| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 31?|?|?|?|?|?|?|I |?|?|?|?|?|?| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2|?|?|?|?|?|?|?|?| |?|?|?|?|?|?| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1|?|?|?|?|?|?|?|?|?|?|?|?|?|?|?| +-+-+-+- +-+-+-+-+-+-+ 111111 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 Mission: Get all the golds!!, Do not get trapped!! L=Turn Left, R=Turn Right, M=Move, b=Quit F=Hill #Trap =Gold ----- Mars Rover Mapper_-_- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 51?|?|?|?|?|?|?| 11?|?|?|?|?| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4|?|?|?|?|?|?|?||||?|?|?|?|?| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 31?|?|?|?|?|?|?|I ||?|?|?|?|?| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2|?|?|?|?|?|?|?| |v||?|?|?|?|?| +-+-+-+-+-+-+ +-+-+-+-+-+-+-+ 11?|?|?|?|?|?|?|1|18?|?|?|?|?| +-+-+-+-+-+-+-+-+ -+-+-+-+-+-+ 111111 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 Mission: Get all the golds!!, Do not get trapped!! L=Turn Left, R=Turn Right, M=Move, b=Quit Hill #Trap *=Gold Total Command Sequences = 1 [S] Total Commands = 7 [C] Total Golds = 0 [G] out of 4 Total Score = [G] x 50 - [S] x 5 - [C] x 1 = -12 Example Sequence: MMLMMMRMMRMRMLLL Enter command sequence => RMRMMMRM Total Command Sequences = 0 [S] Total Commands = 0 [C] Total Golds = [G] out of 4 Total Score = [G] x 50 - [S] x 5 - [C] x x 1 - 0 Example Sequence: MMLMMMRMMRMRMLLL Enter command sequence => MLMLLMM Mars Rover Mapper +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 51?|?|?|?|?|?|?|?|?|?|?|?|?|?|?| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4|?|?|?|?|?|?|?|?| |?|?|?|?|?|?| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 31?|?|?|?|?|?|?1>1 1?|?|?|?|?|?| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 21?|?|?|?|?|?|?|?| ?|?|?|?|?|?| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1|?|?|?|?|?|?|?|?|?|?|?|?|?|?|?| +-+-+-+ +-+-+-+-+ --_--_ Mars Rover Mapper +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5121?|?|?|?|?|I|>1112121212121 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 41?|?|?|?|?|?|II||?|?|?|?|?| +-+-+-+-+-+-+-+-+ -+-+-+-+-+-+ 31?????? 1 ????? +-+-+-+-+-+-+-+-+ -+-+-+-+-+-+ 21?|?|?|?|?|?1 12121212121 +-+-+-+-+-+ -+-+-+-+-+-+ 11??|?|?|?|?| # 1#1?|?|?|?|?1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 111111 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 Mission: Get all the golds!!, Do not get trapped!! L=Turn Left, R=Turn Right, M=Move, Q=Quit Fill #-Trap *=Gold The student is to create a small game that simulates the control of the Mars Rover. Sample sessions of an actual such basic program is provided for your reference in the Figure in the next section of this document. Take note that the program generates everything on the display. Those parts that required user's response (after the "=>" symbol) are to be typed by the user. TCP1101 Programming Fundamentals Assignment #2 Trimester 2, 2020/21 Take note that this is only the minimal basic requirement; you should add as much features as possible to your program and to make it as user-friendly as possible in order to get better marks. Recommendation on how to develop the program: a. Create a class named Map which would be used to create the following: The actual Map of Mars, which is to be hidden from the user and will only be displayed to the user at the end of the game. The Mars Rover Mapper, which keeps track of the cells in the map the Rover had already observed. b. One possible minimal class declaration for Map is shown below: class Map { private: vector > map; int dimx, dimY; public: Map (int dimx, int dimy); void resize (int dimx, int dimy, char ch); void display(); void setObject(int n, int y, char ch); char getObject (int x, int y); bool isEmpty (int x, int y); bool isHill(int x, int y); bool isTrap (int x, int y); bool isInsideMap (int x, int y); int getDimx(); int getDimy(); }; //Map c. Create a class named Rover, which would be used to keep track of the location and heading of the Rover. One possible minimal class declaration is shown below. class Rover { private: int x,y; Direction heading; char object UnderRover; Map* p_mars; I/a pointer to the map for Mars Map mapper; l/a map that keeps track of observed cells so far public: Rover(); void land (Map& mars); //links a map of Mars to a Rover bool turn Left(); bool turnRight(); bool move(); void displayMapper(); bool executeCommand (char command); }; //Rover d. The class declarations above are only the bare minimal, you may want to add member d. The class declarations above are only the bare minimal, you may want to add member functions and data member such as for keeping track of golds collected etc. TCP1101 Programming Fundamentals Assignment #2 Trimester 2, 2020/21 e. The data type Direction can be defined using enumeration as shown below. Please refer to your textbook on how to use enum. enum Direction { north = 0, east = 1, south = 2, west = 3 }; f. As the Rover moves across the map, it would be able to read the three cells just in front of it. g. There are hills on the map which prevent the Rover from moving to those cells. h. There are traps on the map, if the Rover moves to any of those cells, the mission is failed. i. You are free to design your scoring system and other type of cells, you may also introduce new challenges for the Rover. Sample Session of a Demo Program is shown below. Let's explore Mars... Mars dimension X => 15 Mars dimension Y => 5 No of Golds => 4 - Mars Rover Mapper +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 51?|?|?|?|?|?|?|?|?|?|?|?|?|?|?| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 41?|?|?|?|?|?|?|?| ?|?|?|?|?|?| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 31?|?|?|?|?|?|?|I |?|?|?|?|?|?| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2|?|?|?|?|?|?|?|?| |?|?|?|?|?|?| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1|?|?|?|?|?|?|?|?|?|?|?|?|?|?|?| +-+-+-+- +-+-+-+-+-+-+ 111111 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 Mission: Get all the golds!!, Do not get trapped!! L=Turn Left, R=Turn Right, M=Move, b=Quit F=Hill #Trap =Gold ----- Mars Rover Mapper_-_- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 51?|?|?|?|?|?|?| 11?|?|?|?|?| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4|?|?|?|?|?|?|?||||?|?|?|?|?| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 31?|?|?|?|?|?|?|I ||?|?|?|?|?| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2|?|?|?|?|?|?|?| |v||?|?|?|?|?| +-+-+-+-+-+-+ +-+-+-+-+-+-+-+ 11?|?|?|?|?|?|?|1|18?|?|?|?|?| +-+-+-+-+-+-+-+-+ -+-+-+-+-+-+ 111111 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 Mission: Get all the golds!!, Do not get trapped!! L=Turn Left, R=Turn Right, M=Move, b=Quit Hill #Trap *=Gold Total Command Sequences = 1 [S] Total Commands = 7 [C] Total Golds = 0 [G] out of 4 Total Score = [G] x 50 - [S] x 5 - [C] x 1 = -12 Example Sequence: MMLMMMRMMRMRMLLL Enter command sequence => RMRMMMRM Total Command Sequences = 0 [S] Total Commands = 0 [C] Total Golds = [G] out of 4 Total Score = [G] x 50 - [S] x 5 - [C] x x 1 - 0 Example Sequence: MMLMMMRMMRMRMLLL Enter command sequence => MLMLLMM Mars Rover Mapper +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 51?|?|?|?|?|?|?|?|?|?|?|?|?|?|?| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4|?|?|?|?|?|?|?|?| |?|?|?|?|?|?| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 31?|?|?|?|?|?|?1>1 1?|?|?|?|?|?| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 21?|?|?|?|?|?|?|?| ?|?|?|?|?|?| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1|?|?|?|?|?|?|?|?|?|?|?|?|?|?|?| +-+-+-+ +-+-+-+-+ --_--_ Mars Rover Mapper +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5121?|?|?|?|?|I|>1112121212121 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 41?|?|?|?|?|?|II||?|?|?|?|?| +-+-+-+-+-+-+-+-+ -+-+-+-+-+-+ 31?????? 1 ????? +-+-+-+-+-+-+-+-+ -+-+-+-+-+-+ 21?|?|?|?|?|?1 12121212121 +-+-+-+-+-+ -+-+-+-+-+-+ 11??|?|?|?|?| # 1#1?|?|?|?|?1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 111111 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 Mission: Get all the golds!!, Do not get trapped!! L=Turn Left, R=Turn Right, M=Move, Q=Quit Fill #-Trap *=Gold

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!