import java.util.*; /** * * * @author Chris Thiel * @version 8 may 2008 */ public class Trip { // instance variables private ArrayList flights; /** * Constructor for objects of class Trip */ public Trip() { flights = new ArrayList(); } /** @return the number of minutes from the departure of the * first flight to the arrival * of the last flight if there are one or more flights * in the trip; * 0, if there are no flights in the trip */ public int getDuration() { // part a } /** @return the number of minutes from the departure of the * first flight to the arrival of the last flight if there * are one or more flights in the trip; * 0, if there are no flights in the trip */ public int getShortestLayover() { // part b } public void add(Flight f) { flights.add(f); } public static void main(String[] args) { Trip empty= new Trip(); Trip vacation=new Trip(); vacation.add(new Flight(new Time(11,30), new Time(12,15))); vacation.add(new Flight(new Time(13,15), new Time(15,45))); vacation.add(new Flight(new Time(16,0), new Time(18,45))); vacation.add(new Flight(new Time(22,15), new Time(23,0))); System.out.println("Empty duration "+empty.getDuration()); System.out.println("Vacation duration: "+vacation.getDuration()); System.out.println("Empty Shortest Layover: "+empty.getShortestLayover()); System.out.println("Vacation Shortest Layover: "+vacation.getShortestLayover()); } }