Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

33 (a) Create a JAVA program with the class definition below for Aircraft and include accessors and mutators for the attributes, and the display() method

33 (a) Create a JAVA program with the class definition below for Aircraft and include accessors and mutators for the attributes, and the display() method shown

public class Aircraft {

Private int range;

private int fuelCapacity;

public Aircraft() {

range = 0;

fuelCapacity = 0;

}

}

public void display() {

system.out.println(Aircraft range: + range);

system.out.println(Aircraft fuel capacity: + fuelCapacity);

}

33 (b) Add a derived class to the program named Commercial with a private instance variable named seats and a display() method that overrides the display method in Aircraft (see output below). Write a constructor for the derived class with parameters for range, fuel capacity, and seats. In the main method, create an instance of the Commercial class with 23 seats, a range of 1500 miles, and a fuel capacity of 665 gallons, and call the display() method.

Commercial Aircraft

Aircraft range: 1500

Aircraft fuel capacity: 665

Aircraft seating: 23

33 (c) Add a class definition to the program for a class named Cargo that is derived from the Aircraft class. Include an instance variable for payload that is initialized by the constructor, and a display() method to override the inherited method as shown. In the main method, create an instance of the Cargo class

with a payload of 3680 pounds, a range of 870 miles, and a fuel capacity of 335 gallons, and call the display() method.

Cargo Aircraft

Aircraft range: 1500

Aircraft fuel capacity: 665

Aircraft payload: 3680

33 (d) Modify the Aircraft base class by deleting the body of the display() method and make it abstract, and add the abstract modifier to the class.

33 (e) Add a static variable called planes to the Aircraft base class and modify the constructors of the derived classes to increment the variable. Add an output statement to the main method to display the number of planes before and after they are created.

33 (f) Draw a UML diagram of the Aircraft and Commercial classes, their attributes and methods, and indicate their relationship.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Accounting Act Count Think

Authors: Raad Press

1st Edition

979-8643677666

More Books

Students also viewed these Accounting questions