Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Its a c++ problem. Write a class named Car that has the following member variables: owner-a string that holds the name of owner yearModel-an int
Its a c++ problem.
Write a class named Car that has the following member variables: owner-a string that holds the name of owner yearModel-an int that holds the car's year model make-a string that holds the make of the car speed-an int that holds the car's current speed such that speed > 0. In addition, the class should have the following constructor and other member functions: Constructor The constructor should accept the owner's name, car's year model and make as arguments and assigned to the object's member variables. The constructor should also assign a randomly generated integer (between 100 200, inclusive), to speed variable. Destructor default Accessors and Mutators For all member variables accelerate The accelerate function should add 5 to the speed member variable each time it is called. brake The brake function should subtract 5 from the speed member variable each time it is called. updateStatus The updateStatus function should generate a random integer 0 or 1. If the number is zero it calls brake function otherwise accelerate function. Create a text file carData.txt that contains owner's name, year Model, and make for 5 cars. Write a program that reads data from a file and stores 5 car objects in an array. The program should display the information of each car on screen before the game start. The game starts when the program enters in a loop with 10 iterations. Every iteration of the loop calls updateStatus function of each car. At the end of iterations, display information of each car and announce the winner having highest speed. Store winner car's information in a file, winner.txt
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