glass
pen
clip
papers
heaphones

San Diego State University Coding Lab Worksheet

San Diego State University Coding Lab Worksheet

Description

Create a two-player car race game app. The race is around Lake Tahoe (distance = 100 miles):

  • Start with your UML diagram from PA4 and the sample code from Week 5 (Pr15-6.zipDownload Pr15-6.zip).
  • I attached my UML diagram titled PS4.zip
  • Make any modifications needed to fix class hierarchy design problems. In other words, add/change member variables and functions as needed to easily drive() the cars.
  • Create a new class RaceCar, derived from Car. The declaration and definition for RaceCar should be in separate files.
  • Add private member variable int speed to RaceCar and have the RaceCar constructor initialize speed to a random number between 60 and 80mph. This is plenty fast around Lake Tahoe!
  • Make Car::drive() a pure virtual function.
  • Implement RaceCar::drive() to implement the pure virtual function in RaceCar.
  • Create two RaceCar instances.
  • Fill up the tank for each RaceCar before the race, but don’t worry about running out of gas. (That’s a version 1.1 feature).
  • Use a loop to drive() each RaceCar instance 100 miles around the lake. Every 10 miles, generate a new random speed between 60 and 90mph for both RaceCar instances.
  • Use cout to make the game fun to play. Display the details about each RaceCar, its current speed, its remaining fuel (use the FuelGauge), and its location (use the Odometer) as it zooms around the 100 miles of Lake Tahoe shoreline. Use the drive() loop mentioned above for this.
  • If a RaceCar’s speed goes over 80mph, report a crash and which RaceCar was involved, and end the race.
  • After the race is over, display the results and congratulate the winner.
  • Submit one (1) zipped folder that contains all your source code files. You’ll need to include:
    • the class declarations and definitions for each class, and
    • the app code .cpp file.
    • Don’t forget to provide all needed member functions for each class.