Description
50 points
NE 4499/5599
CS 4499/5599
Computational Engineering with C++
Dr. Leslie Kerby
1. Create Vehicle class.
a) Create a new class called Vehicle.
b) It should have 5 private data members: year, miles, value, manufacturer, and model
Use appropriate data types (ie int, float, bool, string, double, etc)
c) Create public getter and setter methods for the 5 private members, called:
setYear, setMiles, setValue, setManufacturer, setModel, getYear, getMiles, getValue, getManufacturer, getModel Again use appropriate data types, and appropriate argument types (or none).
d) Create a 5-parameter constructor. Create a default constructor which instantiates a 2015 Chevrolet Colorado with 55,000 miles worth $20,000. Use constructor initializers to set the private data members in the constructor.
e) Demonstrate that your constructors and getter and setter methods all work by calling them and printing output to the screen. Include these screenshots in your submission.
2. Create Truck class.
a) Create a derived Truck class which publicly inherits from Vehicle.
b) It should have 2 private data members: awd, towing_capacity
Again use appropriate data types.
c) Create public getter and setter methods for the 2 private members, called:
setAwd, setTowing_capacity, getAwd, getTowing_capacity
d) Create a 7-parameter constructor. Create a default constructor which instantiates a default Vehicle with 4×4 and a towing capacity of 5000 lbs. Use constructor initializers to set the private data members upon instantiation.
e) Demonstrate that your constructors and getter and setter methods all work by calling them and printing output to the screen. Include these screenshots in your submission.
Note: the same note on declaration/implementation of the Vehicle class applies to the Truck class. Just be consistent between the two classes.
3. Create a vector of Trucks.
Hint: Create the vector of trucks with this statement: vector<Truck> trucks;
This will create five default trucks, and you would then use the setter methods to set private member data: trucks.at(0).setYear(2015); // or trucks[0].setYear(2015);
b) Using the getter methods, print out all 7 private member variables for each of the five trucks in the Truck vector (show in an understandable way the 5 trucks you picked). Include a screenshot(s) with your submission.
4. Graduate students only.
a) Find the average value of the 5 trucks.
b) Determine the range of years of the 5 trucks.
c) Determine the range in miles of the 5 trucks.
d) Determine the most common manufacturer (if there is one).
e) Print all this information to the screen in an understandable way.
Attach your source code, screenshots of output, and header (if used) files. Include compiled executables if you wish.




Reviews
There are no reviews yet.