Question
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
public Itinerary(List
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started