BCS 230 Assignment 5 – Inheritance, aggregation You will need to submit 3.hfiles (header files) and 3.cppfiles (implementation files) and the client code, also a .cppfile. Program specifications In...



BCS 230 Assignment 5 – Inheritance, aggregation


You will need to submit 3.hfiles (header files) and 3.cppfiles (implementation files) and the client code, also a .cppfile.


Program specifications


In this assignment,you will be creating three classes:Car,ElectricCar, and Engine.


1.Engine



Member variable


-engineType //Sample value could be "petro", "diesel", "electric", and "hybrid."



Member methods

- parameterized constructor // No default constructor


- getEngineType() //Accessor(getter). (No mutator (setter) should be defined.




2.Car



Member variables

-make //The make field references a String object that holds the make of the car
-speed //The speed field is an
int
that holds the car's current speed


-engine//Datatypehere is classEngine, which entails an aggregation relationship betweenCarandEngine



Member methods


- parameterized constructor.//The constructor should take arguments and assign them to car's
engine

and
make. The constructor should also assign 0 to the speed field. (No default constructor should be defined)
-Accessors (getters) //Appropriate accessor methods should get the values stored in an object's make, speed and engine field. (Note: again, no mutators (setter) here)


-accelerate() //The accelerate method should add 5 to the speed field each time it is called


-brake() //The brake method should subtract 5 from the sped field each time it is called.


3.ElectricCar



Member variable



-batteryCapacity(you could useintordouble)



Member methods


-parameterized constructor //No default constructor


-getter and setter



/*The following two methods are function overriding(overriding base class methods)*/


-accelerate(). //The accelerate method should add 6 to the speed field each time it is called


-brake() // The brake method should subtract 6 from the sped field each time it is called.




4. Inmain()


1) Create an
ElectricCarobject


2) Make function calls the accelerate() twice and brake() once.


3) Display its currentspeedandthe engine type.


Apr 02, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here