Similar to the last assignment, in this assignment, you will create FOUR classes:
- A MainClass
- A Parent (base) Class
- A Child class (subclass1)
- A second Child class (Subclass2)
As a group, choose any entity/concept expect the two examples below) that can be modeled as a Parent class and two different subclasses.
e.g.1: Student Example from the class lecture
- Parent: Student
- Child 1: Grad student
- Child 2 Undergrad student
e.g.2: Vehicle Example from ASG7
- Parent: Vehicle
- Child 1: Car
- Child 2: Plane
Define the parent and two subclasses for it as follow.
You Parent Class should have:
- One meaningful attribute which will be inherited by both children (e.g. attributes ID for student or color for vehicle)
- One parameterized constructor
- One meaningful method which is inherited by both children (e.g. Move() for vehicle)
Hint: don’t forget to compile and test your code before moving on.
Each child class should
- Inherits the parent’s attribute
- Has one specific attribute which is not included in the other child (e.g wingspan in plane class)
- Inherits and extends the parent’s constructor (see how we did it in your ASG7)
- Overrides the parent’s method to do a (slightly) different task as the parent’s method and the other child’s method (e.g. driving for a car and flying for a plane instead of moving for a vehicle)
Once you have designed your parent and children classes, write a MainClass with a main method. Your main method should:
Instantiate an object of each child class, call the method for each child object, and show the outputs. Hint: The outputs should be different since the overridden methods are different.