Exemplo n.º 1
0
  /**
   * Print Body - Prints the body of the XML document
   *
   * @param cardDeck a list of cards to be printed
   * @param PrintWriter so it prints to the same file
   */
  public void printBody(PrintWriter out, ArrayList<Card> cardDeck) {
    // Output the Root Element
    out.write("<carddeck version=\"1.0\">");
    out.println();

    for (int i = 0; i < cardDeck.size(); i++) {
      Card c = cardDeck.get(i);
      // Begin the card
      out.write("\t" + "<card>");
      out.println();
      // Output the Title
      out.write("\t\t" + "<title>" + replaceSpecial(c.getTitle()) + "</title>");
      out.println();
      // Output the Front
      out.write("\t\t" + "<front>" + replaceSpecial(c.getFront()) + "</front>");
      out.println();
      // Output the Back
      out.write("\t\t" + "<back>" + replaceSpecial(c.getBack()) + "</back>");
      out.println();
      // End the Card
      out.write("\t" + "</card>");
      out.println();
    }

    // Output The End of the Root Element
    out.write("</carddeck>");
    out.println();
  }