public void TakeFineFromBalance(object StateObj) { Parking State = (Parking)StateObj; var sum = 0; int price = 0; foreach (var car in State.CarList) { price = Settings.prices[car.CarType]; sum = (car.Balance < 0) ? price * Settings.fine : price; car.ChangeBalance(sum, false); State.TransactionList.Add(new Transaction(car.Id, sum * (-1))); State.EarnedMoney += sum; State.LastMinuteMoney += sum; } }
public void LogLastMinuteMoney(object StateObj) { Parking State = (Parking)StateObj; string log = DateTime.Now.ToString("MM.dd.yyyy HH:mm ") + State.LastMinuteMoney; try { using (StreamWriter sw = new StreamWriter(Settings.filePath, true, Encoding.Default)) { sw.WriteLine(log); } State.LastMinuteMoney = 0; } catch (FileNotFoundException) { Console.WriteLine("File not found!"); } catch (IOException ex) { Console.WriteLine(ex); } }