Beispiel #1
0
        private static void changeState(GarageLogic.Garage i_Garage)
        {
            Console.WriteLine("Please enter the vehicle licence number");
            string licenceNumber = Console.ReadLine();

            Console.WriteLine("Please enter 1 for Repair In Progress, 2 for Repair Complete, 3 for Paid.");
            int chosenState;

            while (!int.TryParse(Console.ReadLine(), out chosenState) ||
                   !(chosenState >= 1 && chosenState <= 3))
            {
                Console.WriteLine("Invalid state. please choose valid state.");
            }

            GarageLogic.Vehicle.eVehicleState vehicleState = GarageLogic.Vehicle.eVehicleState.RepairInProgress;

            switch (chosenState)
            {
            case 1:
                vehicleState = GarageLogic.Vehicle.eVehicleState.RepairInProgress;
                break;

            case 2:
                vehicleState = GarageLogic.Vehicle.eVehicleState.RepairComplete;
                break;

            case 3:
                vehicleState = GarageLogic.Vehicle.eVehicleState.Paid;
                break;
            }

            try
            {
                i_Garage.ChangeVehicleState(licenceNumber, vehicleState);
            }
            catch (Exception ex)
            {
                catchExceptionAndContinue(i_Garage, ex);
            }
        }