Exemplo n.º 1
0
 /// <summary>
 /// Listener on the Combobox for the start station of a single ticket.
 /// Alters the textbox for journey price based on what journey was selected.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void cbStartStation_SelectedIndexChanged(object sender, EventArgs e)
 {
     _startStation = cbStartStation.SelectedItem.ToString();
     cbEndStation.Items.Clear();
     //Update price of ticket
     if (cbEndStation.SelectedItem == null)
     {
         tbSingleJourneyPrice.Text = "£0.00";
     }
     else
     {
         tbSingleJourneyPrice.Text = "£" + _routes.GetRouteByStations((Station)cbStartStation.SelectedItem, (Station)cbEndStation.SelectedItem).GetPrice().ToString();
     }
     foreach (var route in _routes.GetRoutesFromStation((Station)cbStartStation.SelectedItem))
     {
         cbEndStation.Items.Add(route.GetEndPoint());
     }
     if (cbEndStation.Items.Count > 0)
     {
         cbEndStation.SelectedIndex = 0;
     }
     else
     {
         cbEndStation.Text = "";
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Finds the route that the customer has travelled along, checks if it is currently peak time,
        /// checks if the customer currently has free travel and then checks if the customer qualifies for free travel after this journey.
        /// It then chekcs if they have enough balance on their account, subtracts the cost of this journey and then
        /// resets their start and end points for their next journey
        /// </summary>
        /// <returns>True if the customer has sucessfully paid for the journey in some way, false otherwise</returns>
        public bool MakePayment()
        {
            var start = _account.GetStartPoint();
            var end   = _account.GetEndPoint();
            var route = _routeList.GetRouteByStations(start, end);
            var price = route.GetPrice();

            if (start.GetDepartures().GetDeparture(end, _aSmartCard.GetScannedTime()).IsPeakDeparture())
            {
                price *= 1.3m;
            }

            if (_account.GetFreeTravel())
            {
                return(true);
            }
            if (_account.GetTotalPaidByDate(GetScannedTime()) > _dayPassPrice)
            {
                _account.SetFreeTravel(true);
                return(true);
            }
            if (_account.GetBalance() >= price)
            {
                _account.UpdateBalance(-price);
                _account.SetStartPoint(null);
                _account.SetEndPoint(null);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
 private void lbRoutes_SelectedIndexChanged(object sender, EventArgs e)
 {
     lblRoutePrice.Text = (routes.GetRouteByStations((Station)cbSelectStation.SelectedItem, ((Station)lbRoutes.SelectedItem))).GetPrice().ToString();
 }