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(); }
/// <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); }
public GasPump(int gasPumpNumber) { GasPumpNumber = gasPumpNumber; foreach (var oneFuel in GasStation.GetInstance().FuelList) { TapList.Add(new Tap(oneFuel)); } Status = GasPumpStatus.Frei; }
/// <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); }
/// <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); }
/// <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 }); } }
/// <summary> /// Stopt den Tankvorgang /// </summary> public void StopRefuel() { timer.Stop(); GasStation.GetInstance().UpdateTanks(); }