Create a flight class that uses the plane and time class
Course:- JAVA Programming
Reference No.:- EM131599449

Assignment Help
Assignment Help >> JAVA Programming

In this assignment you will practice creating classes and enumerations in the context of a larger system. Overall, we are building pieces of an airline flight booking system. The classes that we are constructing in this assignment will take care of representing the flight data in Java. The final booking system should be able to searching for flights from a list of commercial airlines (e.g. American, United, or Delta), and locate various routes between two airports. The output is somewhat inspired by Google Flights. Don't panic! We go will through this system step by step. For the sake of simplifying the problem, we will make a couple of assumptions:
There is only one timezone.
All flights occur in the same day.
Already provided for you is a file called Driver.java. A "driver" is a common term for the main program that manages a set of objects, and manipulates them. It contains the entry point (main) for an entire project. The file you have been provided contains five static methods that can be called from main. These are testing methods that will run sample operations on the enumerations and classes you will be constructing. Initally, they are all commented out. As you implement parts of the assignment, you should uncomment lines in the test methods, in order to see how your program behaves. Also attached is the file sample_output.txt. This file contains the sample output for running this Driver with all of the included tests. You should check the output of your program against the sample output. Plan to test your files one at a time, for example: make sure to test your Airline and Airport enumerations before you start on Plane. Don't start working on Plane until those two classes work completely. Time is independent of Airline, Airport, and Plane, but is complicated enough that you'll want the experience of implementing those other questions before you started it.
Q1: Create an Airline enumeration. This is adatatypethat represents airlines in our system. Include three values: American, United, and Delta. This should be a single file containing theenumdeclaration. [2 points]
Q2: Create a smart Airport enumeration. This is a datatype that represents airports in our system, and has the ability to change from airport code and city name. Include five values: PHX, LAX, SFO, NRT, and SIN. Also add a static method called getAirportCity. This should be a single file containing the enum declaration, with the method declaration nested inside. (Hint:ExampleSmartEnum contains an example of including a method into an enumeration.) [8 points]
getAirportCity(...) will take an Airport enumeration value as a parameter, and return a String containing the city where that airport is located (e.g., "Phoenix", "Los Angeles", "Tokyo", "San Francisco"). Use a switch statement. Have a default case that returns "Unknown City". Do not implement the switch statement for SIN (Singapore) - we want to test the default case first.
Q3:Create a Plane class. This class will represent a plane in our system. It should contain a constructor, two instance variables (an Airline enumeration, and a String) and three methods (getAirline,getModel, toString) [10 points]
The constructor will take an Airline and String and use them to set up the instance variables.
getAirline(): will return the Airline of the plane (e.g., Airline.United).
getModel(): will return a String containing the model of the plane (e.g., "Boeing 737").
toString(): will return the name of the plane's airline (e.g., "United"), followed by a star (" * "), and the model of the plane (e.g., "Boeing 737").
Q4:Create a Time class. This class will represent a point in time, such as a departure time. It should contain 2 constructors, 2 instance variables (hour and minute), and 10 methods (see below). All methods but toString should be in terms of the 24 hour format. [30 points]
default constructor: Creates a Time object for 12:00AM.
overloaded constructor: Creates a Time object at a specific hour and minute.
getHour(): Returns an integer representing the hour of the Time object.
getMinute(): Returns an integer representing the minute of the Time object.
addHours(...): Updates the object by moving it forward a number of hours.
addMinute(...): Updates the object by moving it forward a number of minutes. (Hint: Be careful that you don't allow minutes to be more than 59.)
addTime(...): Updates the object by moving it forward by the hour and minute from another Time object.
getCopy(...): Returns a new Time object that has the same hour and minute of the existing Time object.
isEarlierThan(...): Returns true if this Time object is earlier than another Time object.
isSameTime(...): Returns true if this Time object is the same as another Time object.
isLaterThan(...): Returns true if this Time object is later than another Time object.
toString(): Returns a string representing the Time object. Uses 12 hour AM/PM format and pads minutes to be two digits. See the sample output for an example.
Q5:Create a Flight class that uses the Plane and Time class. This class will represent a flight between two airports, using a specific Plane, and departing at a specific Time. It should contain a constructor, 7 instance variables (plane, flight number, cost, departure, duration, source, destination), and 9 methods (see below). [25 points]
overloaded constructor: Creates a Flight object that is setup up with a Plane, a flight number, a cost, a departure Time, a duration time, a source Airport, and a destination Airport.
getPlane(): Returns the Plane that operates this flight.
getNumber(): Returns the flight number.
getCost(): Returns the flight cost.
getDestination(): Returns the destination Airport.
getDeparture(): Returns the departure Time.
getArrival(): Returns a Time object with the arrival time (computed from the departure time and duration).
getSource(): Returns a Airport object for the departure location.
toOverviewString(): Returns a String representing an overview of the flight. UseNumberFormatto display the price. See the sample output for an example.
toDetailedString(): Returns a String representing the flight's detail information. See the sample output for an example.

Attachment:- Java Code.rar

Put your comment

Ask Question & Get Answers from Experts
Browse some more (JAVA Programming) Materials
Write a method called addUnevenArrays that takes two arrays, a and b, and returns a new array, c, with alength that is the maximum of the lengths of a and b. Each c[i] is the
Name a product that could be described as both a consumer and business product and discuss why. Describe its attributes, uses and product perceptions of the customers in both
100-300 Words. We often are handling the unexpected in life.  Kids and pets can offer many of these unexpected occurrences. Where do you see life's every day exception and how
You were hired as an analyst to develop a new information system to automate the payroll transactions in a mid-size organization. The proposed system will contain employees'
How does a marketer balance the short-term gains that sales promotion can deliver against the possible negative long-term consequences such promotions might have for brands? U
Use employee data file called employees.txt should comprise at least 5 employee records. Each record stores employee ID number (six digits) last name, first name, middle ini
Consider a function called insertElementAtLocation() in an array based  list data structure. The function will insert an element in an array by shifting the elements in the ar
Design a class named Pet, which should have the following fields: Name - The name field holds the name of a pet. Type - The type field holds the type of animal that is the pet