Sale!

ECE 39595 Homework 2

$30.00

Category:

Homework 2
Note that this is not the best way to code this particular problem. We’ll do it better in a later homework.
Download and unzip the homework file “HW2Assigned”. Under it you will find a directory smidkiff that
has code for a Vehicle class and a Main class.
Your first task is to write two other C++ classes that extend Vehicle. The first is HondaFit, and it defines
the following functions that should be called virtually from Vehicle pointers:
• HondaFit(std::string _color): A constructor that takes a single std::string argument that is the
color, and passes the std::string “Honda Fit” to the Vehicle superclass constructor.
• std::string getModel( ) that returns the model field.
• std::string getColor( ) that returns the color field.
• std::string getEngine( ) that returns “1.5L i-DSI 4 Cylinder”
• std::string getTransmission( ) that returns “manual”.
• int getNumPassengers( ) that returns 5.
• std::string getWarranty( ) that returns “3/36,000 + 5/60,000 Powertrain”.
The second is FordF350 and it defines the following functions that should also be called virtually from
Vehicle pointers:
• FordF350(std::string _color): A constructor that takes a single std::string argument that is the
color, and passes the std::string “Ford F350” to the Vehicle superclass constructor.
• std::string getModel( ) that returns the model field.
• std::string getColor( ) that returns the color field.
• std::string getEngine( ) that returns “7.3L V8
• std::string getTransmission( ) that returns “10 speed automatic”.
• int getNumPassengers( ) that returns 3.
• std::string getWarranty( ) that returns “3/36,000 + 5/60,000 Powertrain”.
Compile each of these and remove all syntax errors, etc., that might have crept in. Then compile it with
main.cpp. You will likely notice an error in main.cpp that getWarranty( ) is not found. Fix Vehicle.java so
that this error goes away. Add a comment to the top of main.cpp explaining what you did.
When there are no more compiler errors, run your program. It should give output that looks like:
HondaFit built
Ford F350 built
HondaFit built
Ford F350 built
HondaFit: color: white, engine: 1.5L i-DSI 4 Cylinder, transmission:
manual, setBelts: 5, warranty: 3/36,000 + 5/60,000 Powertrain
Ford F350: color: green, engine: 7.3L V8, transmission: 10 speed
automatic, setBelts: 3, warranty: 3/36,000 + 5/60,000 Powertrain
HondaFit: color: red, engine: 1.5L i-DSI 4 Cylinder, transmission:
manual, setBelts: 5, warranty: 3/36,000 + 5/60,000 Powertrain
Ford F350: color: yellow, engine: 7.3L V8, transmission: 10 speed
automatic, setBelts: 3, warranty: 3/36,000 + 5/60,000 Powertrain
I am not going to be extremely picky about spaces, etc.
What to turn in:
Rename smidkiff to your login name, zip it (and make it a .zip file, not a 7z or other format) and turn in
your code. We should be able to run your program by going into the directory login and typing make to
both build and run your program. Your turned in assignment should only have .h and .cpp files and no .o
or executable files (e.g., a.out).

Reviews

There are no reviews yet.

Be the first to review “ECE 39595 Homework 2”

Your email address will not be published.