Starting from:

$25

CSCI1302 - Programming Project 2 -  Vehicle Information System - Solved

In this project, you will define interfaces, abstract classes, and concrete classes, all placed in a specific package. You will also use the instanceof operator.  
•      A README.txt file explaining how to compile your program and how to execute it.


1.      Your program (all classes) must be placed in package edu.uga.cs1302.vehicles.

2.      Define an interface called Transporter with the following methods:

int    getMaxPassengers() 

void   setMaxPassengers(int maxPassengers) int    getTopSpeed() void   setTopSpeed(int topSpeed) 

3.      Define an interface called Flyable with methods:

int    getMaxAltitude() 

      void   setMaxAltitude(int maxAltitude)       int    getMaxRange() void   setMaxRange(int maxRange) 

4.      Define an interface called Floatable with methods:

            int    getTonnage() void   setTonnage(int tonnage) 

5.      Define an abstract class called Vehicle, which implements the Transporter interface.  Add the representation of:  

•               vehicle’s name (a model name),

•               vehicle’s manufacturer,

•               vehicle’s year of manufacture,

•               count of the instances of the Vehicle class (using a static variable). Use suitable qualifiers for all fields in the class.

6.      Define a (concrete) class called Automobile as a subclass of Vehicle.  Also, an Automobile has an engine with a given horsepower.

7.      Define a class called Airplane as a subclass of Vehicle. Also, this class should implement the Flyable interface.  Furthermore, an Airplane has a given number of engines.

8.      Define a class called Ship as a subclass of Vehicle.  Also, this class should implement the Floatable interface. Also, a Ship has a given shipping line owner.

9.      Be creative and find more Vehicle kinds (at least two more). One of these new vehicle types (can be imaginary) must be able to both fly and float and should be a direct subclass of Vehicle (for example, a flying boat, such as the PBY Catalina, manufactured years ago by Consolidated Aircraft).

10.  Create three vehicles of each type, with different names and suitable attribute values (you may use fictitious values).

11.  Store the Vehicle objects (above) in an array of type Vehicle.

12.  Display a menu to the user on the screen (before implementing this part, read the notes below):

•   Press 1 to see how many vehicles are in the system.

•   Press 2 to see the name and the class of each vehicle (using getClass()).

•   Press 3 to see which vehicles can fly.

•   Press 4 to see which vehicles can float.

•   Press 5 to see which vehicles can float AND fly.

•   Press 6 to see a description of each vehicle (using toString()).

•   Press h to see brief help information for your system (listing these commands).

•   Press q to terminate the program.

13.  Important notes about the menu:

•   If the user enters anything other than 1, 2, 3, 4, 5, 6, h, or q, the program should print a proper error message, and ask the user to re-enter a number between 1-6 or the letters  'h' (for help) or  'q' (to quit). In other words, your program should not ignore the user input (or even worse, crash), if the user enters a wrong choice.

•   In option 1, the result should be the total number of instances of Vehicle class created so far (use a static variable).

•   For option 2, use getClass()of the Object class get the object’s class.

•   For option 3, use instanceof. The result should contain both name (e.g., Mustang Shelby GT350R, Queen Mary 2, Boeing 787) and type (Automobile, Ship, etc.) of the vehicle.

•   For option 4, use instanceof. The result should contain both name and type of the vehicle.

•   For option 5, use instanceof. The result should contain both name and type of the vehicle.

•   Option 6 above should display all attribute values for all vehicles in the array.  Note that the collection of attributes should be appropriate for a given type of a vehicle. For              example:

 

Type: Automobile 

Name: Mustang Shelby  

      GT350R 

Manufacturer: Ford 

Manufacture year: 2017 

Engine power: 526 hp 

Max passengers: 2 

Top speed: 175 mph 

 

           

Things to note:  
Type: Airplane 

Name: Boeing 787 

Manufacturer: Boeing 

Manufacture year: 2014 

Number of engines: 2 

Max altitude: 43000 ft Max range: 8500 mi

Max passengers: 280 

Top speed: 587 mph 
Type: Ship 

Name: Queen Mary 2 

Manufacturer: Chantiers de 

Atlantique 

Manufacture year: 2004 

Tonnage: 149215  

Owner: Carnival 

Max passengers: 2695 

Top speed: 35 mph 
.

•   You must provide setters and getters for all instance variables in classes.

•   Follow good coding style (proper variable names, indentation, etc).

•   Your design should be reasonably efficient, and in accordance with object-oriented design principles (encapsulation, information hiding, inheritance, etc.).

•   If you are defining a variable as public or protected, briefly mention the reason for that.

•   If you are defining a variable as static or final, briefly mention the reason for that, as well.


More products