Exemplo n.º 1
0
 public void writeData(Book book)
 {
     if (book.getType().Equals("HardCopy"))
     {
         Hardcopy b        = (Hardcopy)book;
         string   bookData = b.getName() + ":" + b.getAuthor() + ":" + b.getGenre() + ":" + b.getType() + ":" + b.getYear();
         File.AppendAllText("BookData.txt", bookData + Environment.NewLine);
     }
     else
     {
         Softcopy b        = (Softcopy)book;
         string   bookData = b.getName() + ":" + b.getAuthor() + ":" + b.getGenre() + ":" + b.getType() + ":" + b.getVersion();
         File.AppendAllText("BookData.txt", bookData + Environment.NewLine);
     }
 }
Exemplo n.º 2
0
 public void writeAllBooks(List <Book> books)
 {
     File.WriteAllText("BookData.txt", String.Empty);
     foreach (var book in books)
     {
         if (book.getType().Equals("HardCopy", StringComparison.OrdinalIgnoreCase))
         {
             Hardcopy b        = (Hardcopy)book;
             string   bookData = b.getName() + ":" + b.getAuthor() + ":" + b.getGenre() + ":" + b.getType() + ":" + b.getYear();
             File.AppendAllText("BookData.txt", bookData + Environment.NewLine);
         }
         else
         {
             Softcopy b        = (Softcopy)book;
             string   bookData = b.getName() + ":" + b.getAuthor() + ":" + b.getGenre() + ":" + b.getType() + ":" + b.getVersion();
             File.AppendAllText("BookData.txt", bookData + Environment.NewLine);
         }
     }
 }