Answered step by step
Verified Expert Solution
Question
1 Approved Answer
3. (50 marks) Using C++ programming language, We want to create a program that controls the movements of an object in a 10x10 grid. Initially,
3. (50 marks) Using C++ programming language, We want to create a program that controls the movements of an object in a 10x10 grid. Initially, the object is at position (0, 0). The controller supports the following commands:
- up(n): the object moves n cells towards the top of the grid
- down(n): the object moves n cells towards the bottom
- turn right (n): the object turns right and moves n cells
- turn left (n): the object turns right and moves n cells
- reboot: the object comes back to cell (0, 0) Consider the following grid:
4 0 0 1 23 4 567 8 9 The new grid after executing the sequence: up(5), turn_right(5), down(2) will look like this 4 0 0 1 23 4 5 6 78 9 The program takes commands from a user as shown in the following example Controller Menu: 1. Up 2. Down 3. Turn Right 4. Turn Left 5. Reboot 6. Show Grid 7. Exit Command "6. Show Grid" displays the grid. Command "7. Exit" allows exiting the program A. Implement the controller's functionalities. Add necessarily checks to ensure that the object does not go out of the grid. Your program should be structured using functions. For example, eaclh command should be implemented in a separate function. (25 marks) we want to add the following commands (25 marks) - cancel (n): The program cancel the last n operations and return the object to the initial position - replay (n): The program replays the last n operations that have been cancelled - position: The problem displays the position of the object (Bonus) Add a second object to the grid. Repeat questions A and B. The two objects should never collide, meaning, they should never end up on the same cell (25 marks) B. CStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started