import java.io.*;

public class TapeClient {

  public static void writeListing(Tape t, String filename) throws IOException {
    PrintWriter out = new PrintWriter(new FileWriter(filename));
    int totalLength = 0;
    for (int i = 0; i < t.getNumberOfPrograms(); i++) {
      int length = t.getLength(i);
      totalLength = totalLength + length;
      out.println(i + ": " + t.getProgram(i) + " " + length);
    }
    out.println("Total length: "      + totalLength);
    out.println("Residual capacity: " + t.getResidualCapacity());
    out.close();
  }
}
