Question: Part A.Create a class called Trip with Private Attributes: tripID (int) location (String) pricePerPerson (double) Public Methods: constructor: Receives values for the attributes as parameters

Part A.Create a class called Trip with

Private Attributes: tripID (int)

location (String)

pricePerPerson (double)

Public Methods:

constructor: Receives values for the attributes as parameters and initializes them.//argument constructor

display: Displays the trip information, including tripID, location, and pricePerPerson.

computeCost: This method takes an integer parameter to represent the number of people coming on the trip, and returns the computed cost using the number of people and pricePerPerson attribute.

Part B. Complete the implementation for a class called Cruise, described below. The Cruise class inherits the class Trip and represents a more specific type of trip package that has a cruise. It has additional attributes to include a list of ports of call, as well as an attribute for cruise fees.

The Cruise class should have the following:

Private Attributes: portsOfCalls(int):number of ports the cruise will stop in

fees (double): fees for the cruise

Public Methods:

constructor: receives all Trip and Cruise attributes as parameters. This constructor initializes the Cruise attributes, and sends the appropriate variables to the super class constructor.

display: Displays the information in the Trip and Cruise classes. (We will need to call a method in the super class within this method.)

computeCost: This method takes an integer parameter for the number of people and computes the cost, which now includes the cruise fees. (We will need to call a method in the super class within this method).

Part C

Completing a main method Complete the main method in the RunCuise class to demo the Cruise class. Declare and initialize variables you will need to initialize a Cruise object. Create an object of the Cruise class and send the appropriate arguments to the constructor. Display the Cruise information by calling the display method. Prompt the user to enter how many people will be going on the trip, and display the cruise cost.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!