import java.io.PrintWriter; import java.io.FileWriter; import java.io.FileReader; import java.io.IOException; import java.util.Scanner; class RoadTrip { public static void main(String args[]) { System.out.println("Hello car world!"); Car stephensDreamCar = new Car("Ferrari","F-1",2025); Car stephensActualCar = new Car("Chevy","Malibu",2001); try { stephensActualCar.drive(4000.5); System.out.println("After driving to NOVA, Stephen's tank is " + stephensActualCar.getTankPerc() + "% full!"); System.out.println("Stephen drives this car: " + stephensActualCar); } catch (Exception e) { System.out.println("An exception was caught! Message: " + e.getMessage()); } // We want the client to be able to do the following things: // 1. Persist an existing Car to disk. try { PrintWriter pw = new PrintWriter( new FileWriter("stephen.car")); stephensActualCar.persist(pw); } catch (IOException e) { e.printStackTrace(); } // 2. Hydrate a new Car from disk. try { Scanner s = new Scanner(new FileReader("ferrari.car")); Car aNewFerrari = new Car(s); System.out.println("The car is " + aNewFerrari); } catch (IOException e) { e.printStackTrace(); } // 3. Persist an entire Caravan to disk. Caravan c = new Caravan(); c.setDest("Daytona Beach"); c.addCar(stephensDreamCar); c.addCar(stephensActualCar); try { PrintWriter pw = new PrintWriter( new FileWriter("fallbreak.caravan")); c.persist(pw); } catch (IOException e) { e.printStackTrace(); } } }