Create a flight class that uses the plane and time class

Assignment Help JAVA Programming
Reference no: EM131599449

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

Reference no: EM131599449

Questions Cloud

How does the amish approach to dolls reflect their worldview : The Catholic Church has a long history of social action. Describe two examples of Catholics taking action to improve the lives of people.
Smokers first start to smoke varies : From generation to generation, the mean age when smokers first start to smoke varies.
Identify a popular news story : Debate which of the major new outlets in the U.S. is the most biased and why. First, identify a popular news story.
Information about overweight adolescents : Enter the following information about overweight adolescents in 1999-2000 into Excel: Children less than 2 years old were 11.6
Create a flight class that uses the plane and time class : 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
Probability of rain and a cancellation : Probabilty of rain is .30. Probabilty of game being cancelled, given it raining, is .50. Whats the probability of rain and a cancellation?
Sampling distribution of the proportion of milk chocolate : Construct the sampling distribution of the proportion of milk chocolate candy bars.
The article you choose can relate to various disciplines : The article you choose can relate to various disciplines within the topics discussed in the modules. For example, your article may cover sport management.
Write a procedural email message to employees reminding them : Write a procedural email message to employees reminding them of standard operating procedures or organizational changes that take the form of step-by-step.

Reviews

Write a Review

JAVA Programming Questions & Answers

  What is the benefit of using layout managers

What is the benefit of using layout managers? When a mouse event is generated how is the location of the click point determined? What layout manager should you use so that every component occupies the same size in the container?

  Banking program that simulates the operation

Write a banking program that simulates the operation of your local bank. Declare the following class

  Create a class named pizza - instantiate pizza objects

Create a class named Pizza class must not have the main method and cannot be run independently. It should be used in driver class to instantiate Pizza objects.

  Write a recursive method that takes a parameter

Write a recursive method that takes a parameter a nonnegative integer and generates the following pattern of stars. If the nonnegative integer

  An api for a library that provides for all these operations

Quaternions can be represented with four (4) real numbers (a,b,c,d). They can be added, subtracted, multiplied and divided. You can multiply a quaternion by a scalar (which produces a quaternion as a result)

  Simulate a simple version of a game called liar dice

The first player claims a Poker hand (see "Hand Ranks" below for legal calls). When making a claim, a player says what all five dice are, not just the name of the hand. For example, a player should say, "I have a full house: three 4s and two 5s," ..

  Create a console program that prompts the user

Create a console program that prompts the user to enter the name and address of their employer and position they hold or the name and address of their favorite restaurant and their favorite meal.Display this information on the screen, each on a se..

  Make a program in java language with classes

Make a program, in JAVA language with classes, that simulates health attending in one business day, according to the information just given.

  Write a complete java program assuming that the variables gp

Write a complete java program Assuming that the variables gpa, deanList and studentName have been declared, you should read in the studentName and gpa from keyboard. Write an if statement that adds 1 to deansList and prints studentName to the standar..

  Print the contents of the array

Prepare a second loop that prints the contents of the array

  Palindrome by doing character replacement

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement.

  Define a class datetime which has integer attributes day

Define a class DateTime which has integer attributes day, month, year and time(Use Military time, 1:00pm is 1300, no colon). Make DateTime Serializable and Comparable.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd