Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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 private

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Guide To Client Server Databases

Authors: Joe Salemi

2nd Edition

1562763105, 978-1562763107

More Books

Students also viewed these Databases questions

Question

How to find if any no. is divisble by 4 or not ?

Answered: 1 week ago

Question

Explain the Pascals Law ?

Answered: 1 week ago

Question

8. Design office space to facilitate interaction between employees.

Answered: 1 week ago