static void Main(string[] args) { Parking carParking = Parking.Instance; if (carParking != null) { manager.CarParking = carParking; } carParking.AddCar(new Car(CarType.BUS, 1234, 1.0)); carParking.AddCar(new Car(CarType.MOTOCYCLE, 1326, 1245)); carParking.AddCar(new Car(CarType.PASSANGER, 1356, 1220)); carParking.AddCar(new Car(CarType.TRUCK, 5633, 1220)); try { manager.ShowMenu(); } catch (Exception ex) { //throw; PushMessage(ex.Message); } }
private void AddCar() { Console.Clear(); Console.WriteLine(addCarMenu); ConsoleKeyInfo enteredKeyCar = Console.ReadKey(); CarType carType; switch (enteredKeyCar.Key) { case ConsoleKey.D1: carType = CarType.Passenger; break; case ConsoleKey.D2: carType = CarType.Truck; break; case ConsoleKey.D3: carType = CarType.Passenger; break; case ConsoleKey.D4: carType = CarType.Motorcycle; break; default: Console.WriteLine("\nSuch type of car doesn't exist, back to menu."); return; } Console.WriteLine("\nAdd balance:"); try { double amount = double.Parse(Console.ReadLine()); parking.AddCar(carType, amount); } catch (FormatException) { Console.WriteLine("Invalid input."); } catch (NotEnoughSpaceException e) { Console.WriteLine(e.Message); } catch (NegativeBalanceException e) { Console.WriteLine(e.Message); } }