001package edu.pdx.cs410J.whitlock;
002
003import edu.pdx.cs410J.AbstractAppointmentBook;
004import edu.pdx.cs410J.AppointmentBookDumper;
005
006import java.io.IOException;
007import java.io.PrintWriter;
008
009public class PrettyPrinter implements AppointmentBookDumper {
010  private final PrintWriter writer;
011
012  public PrettyPrinter(PrintWriter pw) {
013    this.writer = pw;
014  }
015
016  @Override
017  public void dump(AbstractAppointmentBook abstractAppointmentBook) throws IOException {
018    this.writer.println(abstractAppointmentBook.getOwnerName());
019
020    AppointmentBook appointmentBook = (AppointmentBook) abstractAppointmentBook;
021    for (Appointment appointment : appointmentBook.getAppointments()) {
022      this.writer.println(appointment.getDescription());
023      this.writer.println(appointment.getBeginTimeString());
024      this.writer.println(appointment.getEndTimeString());
025
026    }
027  }
028}