Пример #1
0
        public CoinContainer(int coinValue, int maximunCoins)
        {
            _coinsValue   = coinValue;
            _maximunCoins = maximunCoins;
            Coin[] coins = GasStation.GetInstance().GetCoins().Where(c => c.GetValue() == coinValue).ToArray();

            for (int i = 0; i < coins.Count(); i++)
            {
                try
                {
                    _coins[i] = coins[i];
                }
                catch (IndexOutOfRangeException ex)
                {
                    MessageService.AddErrorMessage("Fehler", $"{ex.Message}\r\n{ex.Source}\r\n{ex.StackTrace}");
                }
            }

            //for (int i = 0; i < 20; i++)
            //{
            //    _coins[i] = new Coin(_coinsValue);
            //}

            _percentFilling = 100.0 / _maximunCoins * _coins.Where(x => x != null).Count();
        }
Пример #2
0
 /// <summary>
 /// Erstellt eine neue Instanz, sofern noch keine vorhanden ist und ansonsten wird die vorhandene Instanz zurückgegeben.
 /// </summary>
 /// <returns></returns>
 public static GasStation GetInstance()
 {
     if (instance == null)
     {
         instance = new GasStation();
     }
     return(instance);
 }
Пример #3
0
 public GasPump(int gasPumpNumber)
 {
     GasPumpNumber = gasPumpNumber;
     foreach (var oneFuel in GasStation.GetInstance().FuelList)
     {
         TapList.Add(new Tap(oneFuel));
     }
     Status = GasPumpStatus.Frei;
 }
Пример #4
0
        /// <summary>
        /// Erstellt die Tankstelle, damit Sie einstatzfähig ist.
        /// </summary>
        public static GasStation Generate()
        {
            GasStation            gasStation           = GasStation.GetInstance();
            IConfigurationManager configurationManager = ConfigurationManager.CreateInstance();

            gasStation.SetConfigurationManager(configurationManager);
            gasStation.GetTanks();
            gasStation.GetFuels();
            gasStation.GetReceipt();
            gasStation.GetGasPumps();
            gasStation.ChashRegister = new CashRegister(gasStation.GasPumpList);
            return(gasStation);
        }
Пример #5
0
        /// <summary>
        /// Erstellt eine Rechnung
        /// </summary>
        /// <param name="gasPump"></param>
        /// <returns></returns>
        public Receipt CreateReceipt(GasPump gasPump)
        {
            Receipt receipt = new Receipt();

            receipt.RelatedFuel  = gasPump.ActiveTap.Fuel;
            receipt.RelatedLiter = float.Parse(gasPump.Liter.ToString());
            receipt.Sum          = gasPump.ToPayValue;
            DateTime    datum  = DateTime.Now;
            CultureInfo german = new CultureInfo("de");

            receipt.Date = DateTime.Parse(DateTime.Parse(datum.ToString()).ToString("yyyy/MM/dd HH:mm:ss"));
            GasStation.GetInstance().AddReceipt(receipt);
            return(receipt);
        }
Пример #6
0
        /// <summary>
        /// Schliesst die Eingabe vom Geld ab und gibt das Rückgeld
        /// </summary>
        /// <param name="gasPump"></param>
        /// <returns>Das Rückgeld oder -1 wenn noch zu wenig Geld eingeworfen wurde</returns>
        public int[] FinishInput(GasPump gasPump)
        {
            AcceptValueInput();
            int inputValue  = GetValueInput();
            int outputValue = inputValue - Convert.ToInt32((gasPump.ToPayValue * 100));

            if (decimal.Parse(inputValue.ToString()) / 100 >= gasPump.ToPayValue)
            {
                int[] outputCoins = new int[1];
                outputCoins = GetChange(outputValue).CountCoins();
                GasStation.GetInstance().DeleteCoins();
                List <Coin> coins = new List <Coin>();
                foreach (var oneContainer in containers)
                {
                    coins.AddRange(oneContainer.GetCoins().Where(c => c != null));
                }
                GasStation.GetInstance().UpdateCoins(coins);
                return(outputCoins);
            }
            else
            {
                return(new int[] { -1 });
            }
        }
Пример #7
0
 /// <summary>
 /// Stopt den Tankvorgang
 /// </summary>
 public void StopRefuel()
 {
     timer.Stop();
     GasStation.GetInstance().UpdateTanks();
 }