Lab Assignment 9

(April 19/April 20)

 

Note: You can do this lab on your own or with a partner.

 

The main purpose of this lab is to understand more thoroughly some of the inheritance concepts we covered in class. For today's lab we will work with following four classes.

 

  1. Inventory
  2. Vehicle
  3. Car
  4. Bicycle

 

The main functionalities of the classes are explained below. Based on this, you will design and implement these classes. I will also let you think more about the method signatures.

 

Vehicle

This class should abstract the main similarities between a car and a bicycle. You should decide some of the fields and methods of this class. All the fields of this class should be declared private. Though there could be a lot of fields, just limit yourself to maximum 3 or 4.

 

Car

This class should be a subtype of Vehicle class. It should extend functionality of Vehicle class by adding fields and methods that are more relevant to a car. Again limit yourself to just 2-3 more fields and methods.

 

Bicycle

This class should also subtype Vehicle class. It should extend functionality of Vehicle class by adding fields and methods that are more relevant to a bicycle. Limit yourself to just 2-3 more fields and methods.

 

Inventory

The inventory class will keep track of all the vehicles. This class should use an ArrayList to store information about vehicles.

 

Your class diagram should be as shown below: