Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

create test cases class Flight { private String flightNo; private Calendar departureTime; private Calendar arrivalTime; public Flight(String flightNo, Calendar departureTime, Calendar arrivalTime) { this.flightNo =

create test cases

class Flight {

private String flightNo;

private Calendar departureTime;

private Calendar arrivalTime;

public Flight(String flightNo, Calendar departureTime,

Calendar arrivalTime) {

this.flightNo = flightNo;

this.departureTime = departureTime;

this.arrivalTime = arrivalTime;

}

public int getFlightTime() {

return (int)(arrivalTime.getTimeInMillis() - departureTime.getTimeInMillis())

/ (1000 * 60);

}

public Calendar getDepartureTime() {

return departureTime;

}

public Calendar getArrivalTime() {

return arrivalTime;

}

public void setArrivalTime(Calendar arrivalTime) {

this.arrivalTime = arrivalTime;

}

public void setDepartureTime(Calendar departureTime) {

this.departureTime = departureTime;

}

}

class Itinerary {

private List flights;

public Itinerary(List flights) {

this.flights = flights;

}

public int getTotalTravelTime() {

int totalTime = getTotalFlightTime();

for (int i = 0; i < flights.size() - 1; i++) {

long time = flights.get(i + 1).getDepartureTime().getTimeInMillis() -

flights.get(i).getArrivalTime().getTimeInMillis();

totalTime += (int)time / (1000 * 60);

}

return totalTime;

}

public int getTotalFlightTime() {

int flightTime = 0;

for (Flight flight: flights)

flightTime += flight.getFlightTime();

return flightTime;

}

}

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

OCA Oracle Database SQL Exam Guide Exam 1Z0-071

Authors: Steve O'Hearn

1st Edition

1259585492, 978-1259585494

More Books

Students also viewed these Databases questions