예제 #1
0
        public static List <Ship> AllCaptainsAgeLessThan35(Port port)
        {
            List <Ship> ships = new List <Ship>();
            uint        age   = 35;

            foreach (Ship ship in port.GetShips())
            {
                if (ship.CaptainAge < age)
                {
                    ships.Add(ship);
                }
            }
            return(ships);
        }
예제 #2
0
        public static uint SteamerSeats(Port port)
        {
            uint seats          = 0;
            uint seatsOnSteamer = 10;

            foreach (Ship ship in port.GetShips())
            {
                if (ship.ToString() == "Steamer")
                {
                    seats += seatsOnSteamer;
                }
            }
            return(seats);
        }
예제 #3
0
        public static uint SteamerSeats(Port port)
        {
            uint seats = 0;

            foreach (Ship ship in port.GetShips())
            {
                Steamer steamer = ship as Steamer;
                if (steamer != null)
                {
                    seats += steamer.Seats;
                }
            }
            return(seats);
        }
예제 #4
0
        public static double CalculateDisplacement(Port port)
        {
            double displacement = 0;
            double draft        = 6.5F;
            double width        = 14;

            foreach (Ship ship in port.GetShips())
            {
                if (ship.ToString() == "Sailboat")
                {
                    displacement += draft * width * ship.Delta;
                }
            }
            Debug.Assert(displacement != 0, "В порту нет парусников?((");
            return(displacement);
        }
예제 #5
0
        public static double CalculateDisplacement(Port port)
        {
            double displacement = 0;
            double draft        = 6.5F;
            double width        = 14;
            double delta        = 0.45F;
            double result       = draft * width * delta;

            foreach (Ship ship in port.GetShips())
            {
                if (ship.ToString() == "Sailboat")
                {
                    displacement += result;
                }
            }
            return(displacement);
        }