예제 #1
0
        public override void Embus(Passenger passenger)
        {
            if (Passengers.Count == Capacity)
            {
                Console.WriteLine($"{GetType().Name} maximum capacity reached. Consider start now.");
                return;
            }

            switch (passenger.GetType().Name)
            {
            case "AdultPassenger":
                if (passenger.Pay(Price) > 0)
                {
                    Passengers.Add(passenger);
                }

                break;

            case "ChildPassenger":
                if (ChildChair)
                {
                    if (passenger.Pay(Price) > 0)
                    {
                        Passengers.Add(passenger);
                        ChildChair = false;
                    }
                }
                else
                {
                    Console.WriteLine("No more child chair left.");
                }

                break;
            }
        }
예제 #2
0
        public override void Embus(Passenger passenger)
        {
            if (Passengers.Count == Capacity)
            {
                Console.WriteLine($"{GetType().Name} maximum capacity reached. Consider start now.");
                return;
            }

            switch (passenger.GetType().Name)
            {
            case "AdultPassenger":
                if (passenger.Pay(Price) > 0)
                {
                    Passengers.Add(passenger);
                }

                break;

            case "ChildPassenger":
                if (passenger.Pay(Price * 0.5f) > 0)
                {
                    Passengers.Add(passenger);
                }

                break;

            case "PrivilegedPassenger":
                Passengers.Add(passenger);
                break;
            }
        }