/**
  * This method changes the vehicle status.
  */
 public void ChangeStatus()
 {
     getDetailsForStatusChange();
     try
     {
         r_Garage.ChangeVehicleStatus(m_LicenseNumber, m_NewVehicleStatus);
         ConsoleUtils.ClearConsoleAndWrite("Changed the status of the vehicle successfully");
         ConsoleUtils.PressAnyKeyToContinue();
     }
     catch (Exception e)
     {
         ConsoleUtils.ClearConsoleAndWrite(e.Message);
         ConsoleUtils.PressAnyKeyToContinue();
     }
 }
 /**
  * This method recharges the vehicle.
  * Prints an error according to the error.
  */
 public void Recharge()
 {
     try
     {
         getDetailsForRecharge();
         r_Garage.RechargeVehicle(m_LicenseNumber, m_MinsToCharge / 60);
         string chargingMessage = m_CheckForEnergyType ? "Vehicle was charged successfully" : "Vehicle can't be charged";
         ConsoleUtils.ClearConsoleAndWrite(chargingMessage);
         ConsoleUtils.PressAnyKeyToContinue();
     }
     catch (Exception e)
     {
         ConsoleUtils.ClearConsoleAndWrite(e.Message);
         ConsoleUtils.PressAnyKeyToContinue();
     }
 }
예제 #3
0
 /**
  * This method refuels the vehicle.
  * Prints an error according to the error.
  */
 public void Refuel()
 {
     try
     {
         getDetailsForRefuel();
         r_Garage.RefuelVehicle(m_LicenseNumber, m_FuelType, m_AmountForFuel);
         string refuelingMessage = m_CheckForEnergyType
             ? "Refueled the vehicle successfully"
             : "Vehicle cannot be refueled";
         ConsoleUtils.ClearConsoleAndWrite(refuelingMessage);
         ConsoleUtils.PressAnyKeyToContinue();
     }
     catch (Exception e)
     {
         ConsoleUtils.ClearConsoleAndWrite(e.Message);
         ConsoleUtils.PressAnyKeyToContinue();
     }
 }
        /**
         * This method updates the relevant vehicles information.
         * Returns the updates vehicle.
         */
        public Vehicle GetUniqueInfo(Vehicle i_Vehicle)
        {
            List <object> userInputAnswers = new List <object>();

            for (int i = 0; i < i_Vehicle.UniqueInfoList.Count; i++)
            {
                VehicleUniqueInfo information = i_Vehicle.UniqueInfoList[i];
                string            message     = (information.Type == typeof(bool))
                    ? "Please Enter y (yes) if {0} or n (no) if not."
                    : "Enter the {0}";
                ConsoleUtils.ClearConsoleAndWrite(string.Format(message, information.Message));
                if (information.Type.IsEnum)
                {
                    ConsoleUtils.PrintEnum(information.Type);
                }

                string userInput = Console.ReadLine();
                try
                {
                    checkUserInformationInput(userInput, information);
                    if (information.Type == typeof(bool))
                    {
                        userInputAnswers.Add(userInput.Equals("y"));
                    }
                    else
                    {
                        userInputAnswers.Add(userInput);
                    }
                }
                catch (FormatException fe)
                {
                    ConsoleUtils.ClearConsoleAndWrite(fe.Message);
                    ConsoleUtils.PressAnyKeyToContinue();
                    i--;
                }
            }

            i_Vehicle.UpdateUniqueFields(userInputAnswers);

            return(i_Vehicle);
        }
예제 #5
0
        /**
         * This method prints a list of license numbers in the garage.
         */
        public void PrintGarageLicenseNumberList()
        {
            ConsoleUtils.ClearConsoleAndWrite("Would you like to filter the list by vehicle status? enter y / n");
            string needForFilter = checkForValidAnswer(Console.ReadLine());

            if (needForFilter.Equals("y"))
            {
                ConsoleUtils.ClearConsoleAndWrite("Please enter a valid number for a filter.");
                Console.WriteLine(@"The filters are:
1.In repair 
2.Repaired 
3.Payed for");
                Vehicle.eVehicleGarageStatus filter = checkForValidVehicleGarageStatus(Console.ReadLine());
                printList(r_Garage.GetLicenseList(filter));
            }
            else if (needForFilter.Equals("n"))
            {
                printList(r_Garage.GetLicenseList(null));
            }

            ConsoleUtils.PressAnyKeyToContinue();
        }