public TouchInCommand(ICustomer customer, ITfl tfl)
        {
            _customer = customer;
            _tfl      = tfl;

            if (_customer.Balance < 1)
            {
                Console.WriteLine($"Your balance is only £{_customer.Balance}. Please top up.\n");
            }

            else if (_customer.InFlight)
            {
                Console.WriteLine("\nYou must touch out of your current journey before beginning a new one.\n");
            }

            else
            {
                _tfl.PrintStationList();

                var stationName = _tfl.TouchIn();

                if (stationName != Station.None)
                {
                    _customer.TouchIn(stationName);
                }
            }
        }
Пример #2
0
        public TopUpCommand(ICustomer customer, ITfl tfl)
        {
            _customer = customer;
            _tfl      = tfl;

            Console.WriteLine("\nHow much would you like to top up?" +
                              "\nYou can top up the following amounts...\n");

            var topUpOptions = _tfl.TopUpOptions();

            foreach (int topUpOption in topUpOptions)
            {
                Console.WriteLine($"{topUpOption}");
            }
            Console.WriteLine("\n");

            var topUpAmount = _tfl.ValidateInput();

            _customer.TopUp(topUpAmount);
        }
Пример #3
0
        public TouchOutCommand(ICustomer customer, ITfl tfl)
        {
            _customer = customer;
            _tfl      = tfl;

            if (!_customer.InFlight)
            {
                Console.WriteLine("You must touch in to a station before you touch out.\n");
            }

            else
            {
                _tfl.PrintStationList();

                var stationName = _tfl.TouchOut();

                var journey = _customer.TouchOut(stationName);

                var fare = _tfl.CalculateFare(journey);

                _customer.DeductFare(fare);
            }
        }