import java.util.Calendar; import java.util.Date; import expedia.Ticket; import type.lib.CreditCard; public class Traveller { public static void main(String[] args) { // get a new credit card CreditCard card = new CreditCard(123456, "Franck van Breugel"); // determine the travel dates Calendar calendar = Calendar.getInstance(); final int DEPARTING = 245; // September 2 calendar.set(Calendar.DAY_OF_YEAR, DEPARTING); Date departing = calendar.getTime(); final int RETURNING = 255; // September 12 calendar.set(Calendar.DAY_OF_YEAR, RETURNING); Date returning = calendar.getTime(); // buy a ticket Ticket ticket = new Ticket("Toronto", "Amsterdam", departing, returning, card); // try to change the departure date without paying final long CHANGE = 1000 * 60 * 60 * 24L; // one day in milliseconds departing = ticket.getDeparting(); departing.setTime(departing.getTime() + CHANGE); // print ticket System.out.printf("FROM: %s\tTO: %s\nDEPARTURE: %s\nRETURN: %s\n", ticket.getFrom(), ticket.getTo(), ticket.getDeparting(), ticket.getReturning()); // pay for the change final double AMOUNT = 500; card.credit(AMOUNT); ticket.setDeparting(departing); // print ticket again System.out.printf("FROM: %s\tTO: %s\nDEPARTURE: %s\nRETURN: %s\n", ticket.getFrom(), ticket.getTo(), ticket.getDeparting(), ticket.getReturning()); } }