Project #27438 - C ++

Car Class

Write a class named Car that has the following member variables (often called instance 

variables): 

ï‚· 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 

In addition, the class should have the following constructor and other member functions. 

ï‚· Constructor. The constructor should accept the car’s year model and make as arguments. 

These values should be assigned to the object’s yearModel and make member 

variables. The constructor should also assign 0 to the speed member variable. 

ï‚· Accessor. Appropriate accessor functions to get the values stored in an object’s 

yearModel, make, and speed 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. DO NOT allow the vehicle speed to reach a negative number. 

Demonstrate the class in a program that creates a Car object, and then calls the accelerate 

function five times. After each call to the accelerate function, get the current speed of the 

car and display it. Then, call the brake function six times. After each call to the brake 

function, get the current speed of the car and display it.

Subject Computer
Due By (Pacific Time) 04/15/2014 05:00 pm
Report DMCA
TutorRating
pallavi

Chat Now!

out of 1971 reviews
More..
amosmm

Chat Now!

out of 766 reviews
More..
PhyzKyd

Chat Now!

out of 1164 reviews
More..
rajdeep77

Chat Now!

out of 721 reviews
More..
sctys

Chat Now!

out of 1600 reviews
More..
sharadgreen

Chat Now!

out of 770 reviews
More..
topnotcher

Chat Now!

out of 766 reviews
More..
XXXIAO

Chat Now!

out of 680 reviews
More..
All Rights Reserved. Copyright by AceMyHW.com - Copyright Policy