[Solved] An application that shows how class inherit from parent class and implement an interface

$25

File Name: An_application_that_shows_how_class_inherit_from_parent_class_and_implement_an_interface.zip
File Size: 828.96 KB

SKU: [Solved] An application that shows how class inherit from parent class and implement an interface Category: Tag:
5/5 - (1 vote)

Designing an application that shows how class inherit from parent class and implement an interface.

  • Specifications

Class diagram has been provided to follow

<<Interface>>

Vehicle

+drive() : void

+stop() : boolean

+steer : (int)

Car

+doors : Integer

+wheels : Integer

+color : String

Car()

+drive() : void

+stop() : boolean

+steer(int) : void

Ferrari

+Badge : String

+Year : Integer

+Price : Double

Truck

+Gear : Integer

+horn : Integer

Truck()

+drive() : void

+stop() : boolean

+steer(int) : void

+honk() : void

Ford

Ford()

+drive() : void

+stop() : void

+steer(int) : void

+honk() : void

Input

No user input require

Processing

For each class created output the total to the screen.

  • proper use to package is necessary
  • all sub classes must override toString method with simple String message, use System.out.println statement for output
  • create instance variables and method shown in Class diagram for all classes
  • create an interface called Vehicle
  • create a parent class called Car which implements Vehicle interface
  • create a parent class called Truck which implements Vehicle interface
  • create a child class called Ferrari which extends from Car class
  • create a child class called Ford which extends from Truck class
  • create a class called TestClass with main method
  • create instance variable of type ArrayList in TestClass to hold instance of Ferrari and Truck classes
  • add few instances of both classes into ArrayList object
  • loop over ArrayList and call display method of objects in ArrayList

Output

The following is a sample run of the program:

Ferrari class: ### Im a Ferrari car, my color is (some color) and have (no. of doors) doors ###

Ford class: *** Im a Ford truck, and I have (no of gears) gears ***

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] An application that shows how class inherit from parent class and implement an interface
$25