/** Boston University, Department of Computer Science CS 112, Spring 2011 Lab 02: Inheritance, Interfaces, Collections and Generics Teaching Fellow: Diane H. Theriault, deht@cs.bu.edu */ import java.util.*; import java.io.*; public class PartyRunner { public static void main(String[] args) { System.out.println("Welcome to the Party!"); // create some vehicles with passengers from Discovery Channel Shows. Set caravan = new HashSet(); //This collection class does NOT maintain FCFS! addAmericanChopper(caravan); addMythbusters(caravan); addDeadliestCatch(caravan); // Go to party Travel(caravan); // Rock the House Arrive(caravan); } static void addAmericanChopper(Set caravan) { Motorcycle m1 = new Motorcycle("Paul Sr."); Motorcycle m2 = new Motorcycle("Pauli Junior"); Motorcycle m3 = new Motorcycle("Mikey"); caravan.add(m1); caravan.add(m2); caravan.add(m3); } static void addMythbusters(Set caravan) { Car c1 = new Car("Jamie"); c1.addPassenger("Adam"); Car c2 = new Car("Kari"); c2.addPassenger("Grant"); c2.addPassenger("Tory"); caravan.add(c1); caravan.add(c2); } static void addDeadliestCatch(Set caravan) { Ship s1 = new Ship("Phil Harris"); //when you are finished modifying the Ship constructor, //use this version instead: //Ship s1 = new Ship("Phil Harris", "Cornelia Marie"); s1.addPassenger("Jake Harris"); s1.addPassenger("Roger Jensen"); Ship s2 = new Ship("Sig Hansen"); //Ship s2 = new Ship("Sig Hansen", "Northwestern"); s2.addPassenger("Bradford Davis"); s2.addPassenger("Marco"); caravan.add(s1); caravan.add(s2); } static void Travel(Set caravan) { //this is one style of moving through an Iterable container for(Iterator iter=caravan.iterator(); iter.hasNext(); ) { Vehicle vehicle = iter.next(); System.out.println(vehicle.getDriver() + "'s " + vehicle.getName() + " is on it's way! " + vehicle.Go()); } } static void Arrive(Set caravan) { //this is the other style of moving through an Iterable container for(Vehicle vehicle : caravan) { String [] partyGoers = vehicle.getManifest(); if(partyGoers == null) { continue; } for(int i=0; i