static void Main(string[] args) { BookStore boughtBooks = new BookStore(); BookStore soldBooks = new BookStore(); ReadData(boughtBooks, soldBooks); AddHighestPriceOnTitle(boughtBooks, soldBooks); double debt = 0; debt = boughtBooks.Debt() - soldBooks.Debt(); WriteData(soldBooks, debt); }
public static void WriteData(BookStore soldBooks, double debt) { using (StreamWriter sw = new StreamWriter("Rezultatai.txt")) { string topic = String.Format("{0,-10} {1,-17} {2,8} {3,8}", "Leidejas", "Pavadinimas", "Kiekis", "Kaina"); sw.WriteLine(new string('-', 50)); sw.WriteLine(topic); sw.WriteLine(new string('-', 50)); for (int i = 0; i < soldBooks.bookCount; i++) { sw.WriteLine(soldBooks.Book[i]); } sw.WriteLine(); sw.WriteLine(debt); } }
public static double FindHighestPrice(Book targetBook, BookStore boughtBooks) { double max = -1; for (int i = 0; i < boughtBooks.bookCount; i++) { if (targetBook.Title == boughtBooks.Book[i].Title) { if (boughtBooks.Book[i] >= max) { max = boughtBooks.Book[i].Price; } } } return(max); }