Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please ensure to have the member function moveOne. The question has been previously answered but incorrectly. Program 2. For your second program, you will design
Please ensure to have the member function moveOne. The question has been previously answered but incorrectly.
Program 2. For your second program, you will design a class MazeRacer to keep track of where a mouse or human is on a grid, and you will use this class to write an application program that simulates a race between two MazeRacer objects. The application program will create a default racer called Algernon, who starts at (0,0), and it will ask the user to provide the name and starting coordinates names for a second racer. The program then requests target coordinates and a move sequence for each racer (L denotes left, R denotes right, U denotes up, and D denotes down). After moving each racer according to the appropriate move sequence, the program reports where each racer ended up, whether it was at the target, and how many moves were taken. If exactly one racer reached the target, that is the winner; if both reach the target but one took fewer moves, that is the winner; otherwise, you should output Tie!. When you are finished, your program should be able to produce output as below. (User input is highlighted for clarity.) The first maze competitor is Algernon, who will start at (0,0). Enter a name for the second maze competitor: Charlie Enter starting coordinates for Charlie: 1 2 Enter the target coordinates: 3 4 Enter a sequence of moves for Algernon: RRURUUU Enter a sequence of moves for Charlie: RRUL Algernon was at target (3,4) after 7 moves. Charlie was at (2,3) after 4 moves. Algernon wins! OOD requirements: Although you could probably get a program that produces output as above without using classes, the purpose of this problem is to practice class design. Your program should use a separate MazeRacer object to keep track of and process information about each individual racer. Your class must have member variables that keep track of the name, location, and number of moves that have been taken by a racer. The racers don't need to know the target. Your class should have a 1-argument member function moveOne that allows it to move one spot based on the character passed in, and this should be the only way to modify location. Add accessor methods wherever your program needs it. Define at least two constructors; it would be wise for the O-argument constructor to initialize Algernon's name and starting coordinates (0,0). Make good OOD decisions about what should be public and what should be privateStep 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