Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Inheritance and Polymorphism: Trip Planner NOTE: ALL SUPPORTING CLASSES ARE LISTED AS PICTURES DOWN BELLOW For this homework assignment, you will be writing software to

Inheritance and Polymorphism: Trip Planner

NOTE: ALL SUPPORTING CLASSES ARE LISTED AS PICTURES DOWN BELLOW

For this homework assignment, you will be writing software to create helpful documents related to travel done for business and for leisure. Your software will be used to create lists of destinations and records of expenses.

Explanation:

To do this, you will implement an inheritance hierarchy of classes.

Your classes will all be derived from a Trip abstract superclass.

The BusinessTrip class and the LeisureTrip class will be derived from the Trip class.

The RecruitingTrip class is derived from the BusinessTrip class.

The Vacation class, the FamilyReunion class, and the AnniversayTrip class will be derived from the LeisureTrip class.

You will also write an Itinerary class which maintains a list (Vector) of Trip items.

Note: To use the Vector class, you will need to import it (the Enumeration interface will also be useful for cycling through the items in the list):

import java.util.Vector;

import java.util.Enumeration;

The Trip Class

The Trip class is an abstract superclass from which specific types of Trips can be derived.

It contains two data members, the destination and the trip type (tripType).

It also defines a number of methods.

All of the Trip class methods except the getCost() method are defined in a generic way in the file Trip.java (provided)image text in transcribed.

The getCost() method is an abstract method that is not defined in the Trip class because the method of determining the costs varieds based on the type of the trip.

The TravelRecord Class

The TravelRecord class is also providedimage text in transcribed.

It contains constants and needs only be adjusted to contain the name of the hypothetical traveler (i.e. YOUR NAME).

Your code should use the constants included in this file whenever possible.

This class also contains a method to return a string value for the cost of a given trip.

The Derived Classes

All of the classes which are derived from the Trip class must define a constructor. Please see the provided TestItinerary class, TestItinerary.java( provided)image text in transcribed, to determine the parameters for the various constructors. Each derived class should be implemented by creating a file with the correct name, eg., BusinessTrip.java.

What to do:

The BusinessTrip class should be derived from the Trip class.

A BusinessTrip item has number of days, travel cost, total food and lodging cost. These are used to determine its cost. For example, a 3-day trip with a travel cost of 3000 and a total food and lodging cost of 1500 has a total cost of 3000 + 1500, or 4500. A BusinessTrip also has a travel reimbursement and a daily expense reimbursement, these can be used to calculate the total reimbursement amount. The total cost total reimbursement gives the out of pocket amount for that trip.

The LeisureTrip class should be derived from the Trip class. A LeisureTrip item has a total food and lodging cost and a travel cost which are used to determine its cost. For example, a leisure trip with a travel cost of 1500 and a total food and lodging cost of 1500 will cost 3000 dollars.

The FamilyReunion class should be derived from the LeisureTrip class. A FamilyReunion item simply has a travel cost, since you stay at your parents house (i.e. food and lodging are always zero). In addition, the destination never changes (your parents hometown) .

The Vacation class should be derived from the LeisureTrip class. The cost of a Vacation is the cost of the travel plus the cost of the lodging plus the cost of activities.

The AnniversaryTrip class should be derived from the Vacation class. The cost of an AnniversaryTrip is the cost of a Vacation plus an UPGRADE cost (used to pay for nicer travel travel seats, nicer lodgings/food, etc.).

The RecruitingTrip class should be derived from the BusinessTrip class. The cost of a Recruiting Trip is the cost of a BusinessTrip with a higher maximum daily expense reimbursement. The value of the higher reimbursement can be 2 or 3 times higher than normal, depending on the desirability of the candidates being recruited.

Note: To keep things simpler, I recommend using integers for all your numbers. If you want a greater challenge, you are free to use decimal values. I will NOT be checking that your code works correctly with decimal numbers, unless it is obvious that you have designed it to (i.e. by your choice of return values or input values).

The Itinerary Class

The Itinerary class provides methods to enter trips into the travel record, clear the travel record, get the number of trips in the current travel record, get the total cost of the trips (before reimbursements are computed), get the total out of pocket cost for the trips (after the reimbursements are computed), and get a String representing a record for the trips. The Itinerary class must use a Vector to store the Trip items.

Information about the Vector Class can be found here: https://docs.oracle.com/javase/10/docs/api/java/util/Vector.html (Links to an external site.)Links to an external site.

You are free to use any methods of the class that might be helpful.

TO TURN IN:

Your .java files: You should have a separate .java file for every class listed above

A written report (.doc or .docx):

In this report, first sketch out the class hierarchy for the classes described above.

Next, discuss how you approached the assignment and what decisions you made in designing your classes. As an example, you can choose to use protected or private fields in your classes, and you should discuss why you made the choices you did.

I would also like to see a discussion of whatever testing you did as you were programming. I have included a driver class, TestItinerary.javaimage text in transcribed (along with the expected outputimage text in transcribed), that you can use to test your classes. If you did other testing in addition to running this code, please describe it.

Include screenshots of the output you got from whatever testing you did similar (or identical, other than the changes to your name and family reunion destination) to the example output provided.

image text in transcribed

image text in transcribed

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

Ai And The Lottery Defying Odds With Intelligent Prediction

Authors: Gary Covella Ph D

1st Edition

B0CND1ZB98, 979-8223302568

More Books

Students also viewed these Databases questions