Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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).
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)
9 4 ,476% 10:17 AM (1).pdf 0 1 23 S 6 78 9 The new grid after executing the sequence: up(5), turn right5), down(2) will look like this 0 1 2 3 5 6 7 8 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 S. 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 obje not go out of the grid. Your program should be structured using functions. For exampl command should be implemented in a separate function. (25 marks) we want to add the following commands(25 marks): B. cancel (n): The program cancel the last n operations and return the object to the initial p replay In): The program replays the last n operations that have been cancelled position: The problem displays the position of the object C. Bonus) Add a second object to the grid. Repeat questions A and B. The t collide, meaning, they should never end up on the same cell [25 marks)
Step 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