예제 #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Kirjat:");
            Console.WriteLine("___________________");

            bookinfo newbook = new bookinfo("Kesähessumies", "Aki", "0001", 12.50M);

            Console.WriteLine(newbook.PrintInfo());
            Console.ReadKey();
            Console.WriteLine("___________________");
            bookinfo newbook2 = new bookinfo("Mitä kuuluu", "kimmo", "0002", 22.50M);

            Console.WriteLine(newbook2.PrintInfo());
            Console.ReadKey();
            Console.WriteLine("__________________________________");
            Console.WriteLine(newbook.bookcompare(newbook2));
        }
 public string bookcompare(bookinfo book)
 {
     string text;
     Console.WriteLine($"Nimi: {this.title} - Hinta: {this.price.ToString()}");
     Console.WriteLine($"Nimi: {book.title} - Hinta: {book.price.ToString()}");
     if (this.price > book.price)
     {
         text = $"{this.title} on kalliimpi kuin {book.title}";
     }
     else if (this.price == book.price)
     {
         text= $"{this.title} ja {book.title} ovat saman hintaisia.";
     }
     else
     {
         text = $"{book.title} on kalliimpi kuin {this.title}";
     }
     return text;
 }