Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Fruits apples  = new Fruits("Apples", 100, 2);
            Fruits bananas = new Fruits("Bananas", 250, 3);
            Fruits oranges = new Fruits("Oranges", 75, 1);

            apples.ShowFruit(apples);
            Console.WriteLine($"Total price: {apples.Cost(apples)}");

            Console.WriteLine();
            bananas.ShowFruit(bananas);
            Console.WriteLine($"Total price: {bananas.Cost(bananas)}");

            Console.WriteLine();
            oranges.ShowFruit(oranges);
            Console.WriteLine($"Total price: {oranges.Cost(oranges)}");

            int totalPrice = apples.Cost(apples) + bananas.Cost(bananas) + oranges.Cost(oranges);

            Console.WriteLine($"\nTotal price of all fruits: {totalPrice}");

            Console.ReadLine();
        }
 public int Cost(Fruits fruit)
 {
     return(fruit._count * fruit._price);
 }
 public void ShowFruit(Fruits fruit)
 {
     Console.WriteLine(fruit._ID);
     Console.WriteLine($"Quantity: {fruit._count}");
     Console.WriteLine($"Price: {fruit._price}");
 }