コード例 #1
0
        //If the airport already has a passenger with that username,
        //throw an InvalidOperationException with the message "Passenger {username} already registered!".
        //The command adds a new passenger into the airport and returns "Registered {passenger.Username}"
        public string RegisterPassenger(string userName)
        {
            IPassenger passenger = airport.GetPassenger(userName);

            if (passenger != null)
            {
                throw new InvalidOperationException($"Passenger {userName} already registered");
            }
            passenger = new Passenger(userName);
            airport.AddPassenger(passenger);
            return($"Registered {passenger.Username}");
        }