Пример #1
0
        public void DisplayInfo()
        {
            Console.WriteLine("Additional dock info: ");
            Console.WriteLine();

            int row = Boats
                      .OfType <RowingBoat>()
                      .Count();
            int pow = Boats
                      .OfType <PowerBoat>()
                      .Count();
            int sail = Boats
                       .OfType <SailBoat>()
                       .Count();
            int cata = Boats
                       .OfType <Catamaran>()
                       .Count();
            int carg = Boats
                       .OfType <CargoShip>()
                       .Count();

            var weight = Boats
                         .GroupBy(b => b.Weight)
                         .Sum(b => b.Key);

            var speed = Boats
                        .GroupBy(b => b.MaxSpeed)
                        .Sum(b => b.Key);

            var emptySlot = Docks
                            .Count(b => b == null);

            int speedInKMH = speed / Boats.Count();

            Console.WriteLine("Number of docked boats: ");
            Console.WriteLine($"Rowingboat: {row}");
            Console.WriteLine($"Powerboat: {pow}");
            Console.WriteLine($"Sailboat: {sail}");
            Console.WriteLine($"Catamaran: {cata}");
            Console.WriteLine($"Cargoship: {carg}");
            Console.WriteLine($"Total weight in dock: {weight} kg");
            Console.WriteLine($"Average maximum speed in dock: {(speedInKMH * 1.85200)} km/h");
            Console.WriteLine($"Empty slots in dock: {emptySlot/2}");
            Console.WriteLine($"Number of total boats added: {AddedBoats}");
            Console.WriteLine($"Number of total boats rejected: {RejectedBoats}");
        }