Exemplo n.º 1
0
        /// <summary>
        /// Constructor method
        /// </summary>
        /// <param name="v">Vehicle</param>
        /// <param name="p">Pump</param>
        /// <param name="l">Number of litres</param>
        public Transaction(Vehicle v, Pump p, double l)
        {
            Vehicle        = v;
            Pump           = p;
            NumberOfLitres = l;
            TransactionID  = TransactionNumber++;
            switch (v.FuelType)
            {
            case "Unleaded":
                Cost = l * Counters.UnleadedPrice;
                break;

            case "LPG":
                Cost = l * Counters.LPGPrice;
                break;

            case "Diesel":
                Cost = l * Counters.DieselPrice;
                break;
            }
            Counters.TotalProfit += Cost;
        }
Exemplo n.º 2
0
        public static void FinishTransaction(object sender, ElapsedEventArgs e, Vehicle v, Pump p, double l)
        {
            if (p.Enabled)
            {
                Transaction transaction = new Transaction(v, p, l);
                p.PictureBox.Image = Properties.Resources.picPumpFree;
                p.CurrentVehicle   = null;
                Counters.VehiclesServed++;
                switch (v.FuelType)
                {
                case "Unleaded":
                    Counters.TotalUnleaded += l;
                    break;

                case "LPG":
                    Counters.TotalLPG += l;
                    break;

                case "Diesel":
                    Counters.TotalDiesel += l;
                    break;
                }

                Counters.Transactions.Add(transaction);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Method checking if the referenced pump is not blocked by the pump before in the lane.
        /// </summary>
        /// <param name="p">Pump to be checked.</param>
        /// <returns></returns>
        public static bool PumpAvailable(Pump p)
        {
            switch (p.PumpID)
            {
            case 7:
                if (p.IsEmpty())
                {
                    return(true);
                }
                else
                {
                    return(false);
                }

            case 4:
                if (p.IsEmpty())
                {
                    return(true);
                }
                else
                {
                    return(false);
                }

            case 1:
                if (p.IsEmpty())
                {
                    return(true);
                }
                else
                {
                    return(false);
                }

            case 8:
                if (p.IsEmpty() && Data.pumps[6].IsEmpty())
                {
                    return(true);
                }
                else
                {
                    return(false);
                }

            case 5:
                if (p.IsEmpty() && Data.pumps[3].IsEmpty())
                {
                    return(true);
                }
                else
                {
                    return(false);
                }

            case 2:
                if (p.IsEmpty() && Data.pumps[0].IsEmpty())
                {
                    return(true);
                }
                else
                {
                    return(false);
                }

            case 9:
                if (p.IsEmpty() && Data.pumps[7].IsEmpty() && Data.pumps[6].IsEmpty())
                {
                    return(true);
                }
                else
                {
                    return(false);
                }

            case 6:
                if (p.IsEmpty() && Data.pumps[4].IsEmpty() && Data.pumps[3].IsEmpty())
                {
                    return(true);
                }
                else
                {
                    return(false);
                }

            case 3:
                if (p.IsEmpty() && Data.pumps[1].IsEmpty() && Data.pumps[0].IsEmpty())
                {
                    return(true);
                }
                else
                {
                    return(false);
                }

            default:
                return(false);
            }
        }