Question
Car Class Write a class namedCar that has the following member variables: yearModel . Anint that holds the cars year model. make . A string
Car Class Write a class namedCar that has the following member variables: yearModel . Anint that holds the cars year model. make . A string that holds the make of the car. speed . Anint that holds the cars current speed. V ideoNote Solving the Employee Class Problem Programming Challenges 803 In addition, the class should have the following constructor and other member functions. Constructor. The constructor should accept the cars year model and make as arguments. These values should be assigned to the objectsyearModel andmake member variables. The constructor should also assign 0 to thespeed member variables. Accessor. Appropriate accessor functions to get the values stored in an objects yearModel,make, andspeed member variables. accelerate . Theaccelerate function should add 5 to thespeed member variable each time it is called. brake . Thebrake function should subtract 5 from thespeed member variable each time it is called. Demonstrate the class in a program that creates aCar object, and then calls the accelerate function five times. After each call to theaccelerate function, get the current speed of the car and display it. Then, call thebrake function five times. After each call to thebrake function, get the current speed of the car and display it
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