Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

11.3 (Flight time) Design two classes: Flight and Itinerary. The Flight class stores the information about a flight with the following members: 1. A data

11.3 (Flight time) Design two classes: Flight and Itinerary. The Flight class stores the information about a flight with the following members: 1. A data field named flightNo of the String type with getter method. 2. A data field named departureTime of the GregorianCalendar type with getter and setter methods. 3. A data field named arrivalTime of the GregorianCalendar type with getter and setter methods. 4. A constructor that creates a Flight with the specified number, departureTime, and arrivalTime. 5. A method named getFlightTime() that returns the flight time in minutes. The Itinerary class stores the information about itinerary with the following members: 1. A data field named flights of the List type. The list contains the flights for the itinerary in increasing order of departureTime. 2. A constructor that creates an Itinerary with the specified fights. 3. A method named getTotalTravelTime() that returns the total travel time in minutes from the depature time of the first flight to the arrival time of the last flight in the itinerary. 4. A method named getTotalFlightTime() that returns the sum of the flight time for all flights in the itinerary. The flight time of a flight is defined as the time from the departure time of the flight until its arrival time. Implement these two classes and use the follwing program to test these classes. public static void main(String[] args) { List flights = new ArrayList<>(); flights.add(new Flight("US230", new GregorianCalendar(2014, 4, 5, 5, 5, 0), new GregorianCalendar(2014, 4, 5, 6, 15, 0))); flights.add(new Flight("US235", new GregorianCalendar(2014, 4, 5, 6, 55, 0), new GregorianCalendar(2014, 4, 5, 7, 45, 0))); flights.add(new Flight("US237", new GregorianCalendar(2014, 4, 5, 9, 35, 0), new GregorianCalendar(2014, 4, 5, 12, 55, 0))); Itinerary itinerary = new Itinerary(flights); System.out.println(itinerary.getTotalTravelTime()); System.out.println(itinerary.getTotalFlightTime()); }

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_2

Step: 3

blur-text-image_3

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

How To Build A Million Dollar Database

Authors: Michelle Bergquist

1st Edition

0615246842, 978-0615246840

More Books

Students also viewed these Databases questions

Question

Identify the three general schools of counseling.

Answered: 1 week ago