Question
Write a class named Car that has the following member variables: a string that holds the name of the owner, an int that holds the
Write a class named Car that has the following member variables: a string that holds the name of the owner, an int that holds the car's year model, a string that holds the make of the car, an int that holds the car's current speed, such that speed0. 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 arguments and assigned them to the object's member variables. The constructor should also assign a randomly generated integer(between 100200, inclusive) to the speed variable. Destructor-default. Accessors and Mutators for all member variables. AccelerateThe accelerate function should add 5 to the speed member variable each time it is called. BrakeThe brake function should subtract 5 from the speed member variable each time it is called. updateStatusThe 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 the owner's name, yearModel, 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 the highest speed. Store winner car's information in a file, winner.txt.
Language: C++
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