Esempio n. 1
0
        /// <summary>
        /// Return the value of paking lot income for last minute.
        /// </summary>
        /// <returns>Return the income of paking lot for last minute.</returns>
        public static double ShowLastMinuteIncome()
        {
            double             income = 0;
            List <Transaction> tr     = new List <Transaction>(Parking.GetInstance().transactions);

            foreach (Transaction t in tr.ToArray())
            {
                income += t.Amount;
            }

            return(income);
        }
Esempio n. 2
0
 public static Parking createParkingLot(int noOfParkingSlots)
 {
     if (parkingLotProcessor != null)
     {
         return(parkingLotProcessor);
     }
     else
     {
         parkingLotProcessor =
             new Parking(noOfParkingSlots);
         return(parkingLotProcessor);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Check whether the vehicle is parked.
        /// </summary>
        public static void TakeVehicle()
        {
            var id = VehicleViewer.ReadLicenseNumber();

            if (VehicleViewer.IsParked(id))
            {
                var v = VehicleViewer.FindVehicle(id);
                check : if (v.Balance < 0)
                {
                    Console.WriteLine($"You have a debt for parking in amount of {v.Balance}. Please fund your account.");
                    VehicleAccount.FundAccount(v);
                    goto check;
                }

                v.IsParked = false;
                Parking.GetInstance().vehicles.Remove(v);
                Console.WriteLine("Taking vehicle is successful.");
            }
            else
            {
                Console.WriteLine($"There is no vehicle with license number {id}");
            }
        }
Esempio n. 4
0
        public void validateandprocess(string str)
        {
            string[] strings = str.Split(' ');
            string   command = findcommand(strings[0]);

            switch (command)
            {
            case "CREATE":
                if (strings.Length != 2)
                {
                    throw new Exception("Invalid no of arguments for command : " + command);
                }
                int noOfPrakingSlots = int.Parse(strings[1]);
                parking = Parking.createParkingLot(noOfPrakingSlots);
                break;

            case "PARK":
                if (strings.Length != 3)
                {
                    throw new Exception("Invalid no of arguments for command : " + command);
                }
                String regNo = strings[1];
                String color = strings[2];
                parking.parkCar(new Car(regNo, color));
                break;

            case "LEAVE":
                if (strings.Length != 2)
                {
                    throw new Exception("Invalid no of arguments for command : " + command);
                }
                int slotNo = int.Parse(strings[1]);
                parking.leaveSlot(slotNo);
                break;

            case "STATUS":
                if (strings.Length != 1)
                {
                    throw new Exception("Invalid no of arguments for command : " + command);
                }
                parking.getStatus();
                break;

            case "FETCH_CAR_FROM_COLOR":
                if (strings.Length != 2)
                {
                    throw new Exception("Invalid no of arguments for command : " + command);
                }
                parking.getRegistrationNumbersFromColor(strings[1]);      //color
                break;

            case "FETCH_SLOT_FROM_COLOR":
                if (strings.Length != 2)
                {
                    throw new Exception("Invalid no of arguments for command : " + command);
                }
                parking.getSlotNumbersFromColor(strings[1]);      //color
                break;

            case "FETCH_SLOT_FROM_REG_NO":
                if (strings.Length != 2)
                {
                    throw new Exception("Invalid no of arguments for command : " + command);
                }
                parking.getSlotNumberFromRegNo(strings[1]);      //regNo
                break;
            }
        }