Пример #1
0
        public Parking()
        {
            timeOut      = Settings.GetSettingsInstance()._timeOut;
            parkingSpace = Settings.GetSettingsInstance()._parkingSpace;
            fine         = Settings.GetSettingsInstance()._fine;
            // set the callback method
            TimerCallback tcm   = new TimerCallback(CalcMoneyTimer);
            TimerCallback tctrn = new TimerCallback(WriteTransactionTimer);

            // create timer
            timerSum   = new Timer(tcm, null, 0, 60000);
            timerTrans = new Timer(tctrn, null, 0, Settings.GetSettingsInstance()._timeOut * 1000);
        }
Пример #2
0
 public void AddCar(Car _c)
 {
     try
     {
         if (ReturnCarsCount() < Settings.GetSettingsInstance()._parkingSpace)
         {
             allCars.Add(_c);
         }
         else
         {
             Console.WriteLine("There are no free places in the parking lot!");
         }
     }
     catch (Exception ex)
     { Console.WriteLine(ex.ToString()); }
 }
Пример #3
0
 public void CalcMoneyTimer(object obj)
 {
     foreach (Car c in allCars)
     {
         decimal price = Settings.GetSettingsInstance().ReturnPriceByType(c._type);
         decimal sum   = c._bill - price;
         if (sum < 0)
         {
             price *= fine;
         }
         c.TakeMoney(price);
         CalcAllMoney(price);
         Transaction trn = new Transaction(c._id, price);
         AddTransaction(trn);
     }
 }