private void printStartPage() { Console.WriteLine("Welcome to Garage Main Dashboard"); Console.WriteLine("================================="); Console.WriteLine(); string msg = @"Choose an action: 1. Insert a car into repair 2. Display a list of license plates filtered by status 3. Change a vehicles status 4. Inflate a vehicle's tiers to maximum 5. Fuel up a vehicle 6. Charge up an electric vehicle 7. Display a vehicle's full data 8. Exit program "; int result = UserCommunicator.getIntInRange(msg + "Pick the number of action you would like to do ", 1, 8); parseAction(result); }
private void InitializFuelEngine() { FuelEngine.eFuelType FuelType; float AmountOfFuel = UserCommunicator.getFloatFromUser("How much fuel do you have left"); float MaxFuelAmount; switch (m_DataBase.m_VehicleType) { case eVehicleType.Car: MaxFuelAmount = 45.0f; FuelType = FuelEngine.eFuelType.Octan98; break; case eVehicleType.Truck: MaxFuelAmount = 115.0f; FuelType = FuelEngine.eFuelType.Octan96; break; default: // eVehicleType.MotorCycle MaxFuelAmount = 6.0f; FuelType = FuelEngine.eFuelType.Octan96; break; } m_DataBase.m_FuelType = FuelType; m_DataBase.m_AmountOfFuel = AmountOfFuel; m_DataBase.m_MaxFuelAmount = MaxFuelAmount; }
private void FuelUp() { string plateNumber = getPlateNumber(); bool fueled = m_Garage.isCustomerEnrolled(plateNumber); if (fueled) { float fuel = UserCommunicator.getFloatFromUser("How much fuel to put in"); FuelEngine.eFuelType type = UserCommunicator.toFuelType( UserCommunicator.getStringThatEqualsOneOf("Fuel Type", new string[] { "Soler", "Octan95", "Octan96", "Octan98" }, false)); try { fueled = m_Garage.FuelVehicle(plateNumber, fuel, type); } catch (Exception e) { Console.WriteLine("Wrong arguments, vehicles haven't been fueled up."); } } else { printNotEnrolled(); } }
private void InitializeCar() { Car.eColor Color = UserCommunicator.ToCarColor(UserCommunicator.getStringThatEqualsOneOf("What color is your car", new string[] { "Grey", "Blue", "White", "Black" }, false)); Car.eNumOfDoors NumOfDoors = UserCommunicator.ToNumOfDoors(UserCommunicator.getIntInRange("How many doors your car have?", 2, 5)); m_DataBase.m_Color = Color; m_DataBase.m_NumOfDoors = NumOfDoors; }
private void InitializeClient() { string Name = UserCommunicator.getStringFromUser("Full Name"); string PhoneNumber = UserCommunicator.getStringFromUser($"{Name}'s phone number"); m_DataBase.m_Name = Name; m_DataBase.m_PhoneNumber = PhoneNumber; }
private void InitializeTruck() { bool RiskyMaterials = UserCommunicator.getBoolFromUser("Does your truck carry risky materials"); float MaxCarry = UserCommunicator.getFloatFromUser("Your truck's max weight carry"); m_DataBase.m_RiskyMaterials = RiskyMaterials; m_DataBase.m_MaxCarry = MaxCarry; }
private void InitializeMotorCycle() { int EngineVolume = UserCommunicator.getIntFromUser("Your motor cycle's engine volume"); MotorCycle.eLicense LicenseType = UserCommunicator.ToLicense(UserCommunicator.getStringFromUser("Your motrorcycle's license type [A/A1/B/B2]")); m_DataBase.m_EnergyPercentage = EngineVolume; m_DataBase.m_LicenseType = LicenseType; }
private void changeCarStatus() { string plateNumber = getPlateNumber(); if (!m_Garage.isCustomerEnrolled(plateNumber)) { printNotEnrolled(); } else { MotorVehicle.eVehicleStatus status = UserCommunicator.ToVehicleStatus( UserCommunicator.getStringThatEqualsOneOf("Pick a status", new string[] { "In Repair", "Payed", "Repaired" }, false)); m_Garage.ChangeStatus(plateNumber, status); Console.WriteLine($"Your car status changed to \"{status}\""); } }
private void InitializeMotorVehicle() { Console.WriteLine("\nMotor Vehicle Questions"); string Manufacture = UserCommunicator.getStringFromUser("Your vehicle's Manufacturer"); float EnergyPercentage = UserCommunicator.getFloatInRange("Your vehicle's energy percentage", 0, 100); m_DataBase.m_Manufacture = Manufacture; m_DataBase.m_EnergyPercentage = EnergyPercentage; InitializeVehicleByType(); List <Wheel> Wheels = UserCommunicator.getWheelsFromUser(m_DataBase.m_VehicleType); m_DataBase.m_Wheels = Wheels; InitializEngine(); }
private void InitializEngine() { bool isElectricEngine = false; if (m_DataBase.m_VehicleType != eVehicleType.Truck) { isElectricEngine = UserCommunicator.getBoolFromUser("Is your vehicle's engine electric"); m_DataBase.m_IsElectric = isElectricEngine; } if (isElectricEngine) { InitializElectricEngine(); } else { InitializFuelEngine(); } }
private void InitializElectricEngine() { float BatteryTimeLeft = UserCommunicator.getFloatFromUser("Your electric engine's battery's remaining time"); float MaxBatteryLife; switch (m_DataBase.m_VehicleType) { case eVehicleType.Car: MaxBatteryLife = 3.2f; break; default: // eVehicleType.MotorCycle MaxBatteryLife = 1.8f; break; } m_DataBase.m_BatteryTimeLeft = BatteryTimeLeft; m_DataBase.m_MaxBatteryLife = MaxBatteryLife; }
private void InitializeVehicleByType() { eVehicleType vehicleType = UserCommunicator.GetVehicleTypeFromUser(); m_DataBase.m_VehicleType = vehicleType; switch (vehicleType) { case eVehicleType.Car: InitializeCar(); break; case eVehicleType.Truck: InitializeTruck(); break; case eVehicleType.MotorCycle: InitializeMotorCycle(); break; } }
private void chargeUpElectric() { string plateNumber = getPlateNumber(); bool charged = m_Garage.isCustomerEnrolled(plateNumber); if (charged) { float amount = UserCommunicator.getFloatFromUser("How much to charge"); try { charged = m_Garage.ChargeVehicle(plateNumber, amount); } catch (Exception e) { Console.WriteLine("Wrong arguments, vehicles haven't been charged"); } } else { printNotEnrolled(); } }
private void parseAction(int i_Action) { Console.Clear(); switch (i_Action) { case 1: string PlateNumber = UserCommunicator.getStringFromUser("Your vehicle's plate number"); if (!m_Garage.isCustomerEnrolled(PlateNumber)) { DataBaseInitializer InitDB = new DataBaseInitializer(); DataBase newCarDataBase = InitDB.InitializeVehicle(); newCarDataBase.m_PlateNumber = PlateNumber; m_Garage.Add(CustomerGenerator.Start(newCarDataBase)); Console.Clear(); Console.WriteLine($"{newCarDataBase.m_Name}, your car have been added, and it's status is \"In Repair\""); } else { string name = m_Garage.FindCustomerByPlateNumber(PlateNumber).Name; Console.WriteLine($"Welcome back {name}, your car status changed to \"In Repair\""); m_Garage.ChangeStatus(PlateNumber, MotorVehicle.eVehicleStatus.inRepair); } break; case 2: DisplayAllPlateNumbersFiltered(); break; case 3: changeCarStatus(); break; case 4: InflateToMax(); break; case 5: FuelUp(); break; case 6: chargeUpElectric(); break; case 7: printVehicleDetails(); break; case 8: Console.WriteLine("Bye Bye\nPress any key to exit..."); Console.ReadLine(); return; } Console.WriteLine("Press any key to continue"); Console.ReadLine(); Console.Clear(); Start(); }
private string getPlateNumber() { return(UserCommunicator.getStringFromUser("What is the plate number of the car")); }