public static void Main() { UiManager uiManager = new UiManager(); ///////////////////////// test Wheel wheels1 = new Wheel("rwewr", 20, 40); Wheel wheels2 = new Wheel("rwewr", 20, 40); Wheel wheels3 = new Wheel("rwewr", 20, 40); Wheel wheels4 = new Wheel("rwewr", 20, 40); Wheel[] wheels = { wheels1, wheels2, wheels3, wheels4 }; Engine gas = new GasEngine(eGasType.Octan96, 30, 40); Engine electric = new ElectricEngine(50, 33); Motor motor = new Motor(eLicenseType.A, 50, "fsdf", "345", 432, wheels, gas, "rewr", 53, 432); Car car = new Car(eCarColors.BLACK, eCarDoors.FOUR, "rerete", "123", 20, wheels, gas, "erew", 40, 70); Car car2 = new Car(eCarColors.BLUE, eCarDoors.FIVE, "baa", "567", 30, wheels, electric, "rer", 42, 50); Truck truck = new Truck(true, 54, "rwe", "789", 25, wheels, gas, "gdds", 30, 50); VehicleInGarage vehicleInGarageMotor = new VehicleInGarage("Erez", "052482542", eVehicleRepairStatus.IN_PROGRESS, motor); VehicleInGarage vehicleInGarageCar = new VehicleInGarage("nofar", "05244324", eVehicleRepairStatus.IN_PROGRESS, car); VehicleInGarage vehicleInGarageCar2 = new VehicleInGarage("C#", "052442134222", eVehicleRepairStatus.IN_PROGRESS, car2); VehicleInGarage vehicleInGaragetruck = new VehicleInGarage("Netta barzilai", "0524461111", eVehicleRepairStatus.IN_PROGRESS, truck); uiManager.m_GarageManager.CurrentVehiclesInGarage.Add("345", vehicleInGarageMotor); uiManager.m_GarageManager.CurrentVehiclesInGarage.Add("123", vehicleInGarageCar); uiManager.m_GarageManager.CurrentVehiclesInGarage.Add("567", vehicleInGarageCar2); uiManager.m_GarageManager.CurrentVehiclesInGarage.Add("789", vehicleInGaragetruck); ////////////////////////// test uiManager.Run(); }
private int getFuelTypeFromUser() { StringBuilder stringOfFuelTypes = new StringBuilder(); foreach (object FuelTypeObject in Enum.GetValues(typeof(GasEngine.eFuelType))) { stringOfFuelTypes.Append( string.Format( "{0}. {1}{2}", (int)FuelTypeObject, FuelTypeObject, Environment.NewLine)); } Console.WriteLine(stringOfFuelTypes); int fuelType = int.Parse(Console.ReadLine()); while (!GasEngine.IsFuelTypeInRange(fuelType)) { Console.WriteLine("Invalid choice. Enter a valid fuel type:"); fuelType = int.Parse(Console.ReadLine()); } return(fuelType); }
public override Car GetCar() { Engine e = null; switch (configurations.Engine.EngineType) { case EEngine.Diesel: e = new DieselEngine(); break; case EEngine.Petrol: e = new PetrolEngine(); break; case EEngine.Gas: e = new GasEngine(); break; } Car newCar = new CustomizedCar(++_iNumberOfCars) { Engine = e, Model = configurations.Model, Base = new Base(), Breaks = new Breaks(), Electronics = new Electronics(), ExhaustingSystem = new ExhaustingSystem(), }; CarEnhancer enh = new CarEnhancer(); enh.Enhance(newCar, configurations.CarType); return(newCar); }
internal static void ShowFuelGasVehicleMenu(GarageLogic i_MyGarage) { Console.Clear(); Console.WriteLine("Please enter vehicle license plate"); string licensePlateNumber = Console.ReadLine(); if (i_MyGarage.CheckIfVehicleIsExists(licensePlateNumber)) { Vehicle userCar = i_MyGarage.GetVehicleByLicensePlate(licensePlateNumber); if (userCar.Engine is GasEngine == false) { Console.Clear(); Console.WriteLine("This vehicle is not Gasoline vehicle "); } else { GasEngine userEngine = (GasEngine)userCar.Engine; float validFuelAmount = getValidFuelAmountOfValidFuelType(userEngine); userEngine.FillUpGas(validFuelAmount, userEngine.GasType); Console.WriteLine("Fueling..."); Thread.Sleep(2000); Console.Clear(); } } else { Console.Clear(); Console.WriteLine("This vehicle is not found in our garage "); } }
private void refuelVehicle() { string licenseNumber = receiveLicenseNumberInput(); if (r_Garage.CheckIfVehicleExistsInGarage(licenseNumber)) { GasEngine vehicleEngine = r_Garage.VehicleDictionary[licenseNumber].Vehicle.Engine as GasEngine; if (vehicleEngine != null) { if (!vehicleEngine.IsEngineFull()) { receiveFuelInputAndRefuelVehicle(vehicleEngine); Console.WriteLine("Vehicle refueled successfully"); } else { Console.WriteLine("The vehicle is already full of gas"); } } else { Console.WriteLine("This vehicle is not gas-powered"); } } else { Console.WriteLine("There is no vehicle with license number: {0} in the garage", licenseNumber); } }
private static float getValidFuelAmountOfValidFuelType(GasEngine userEngine) { Console.Clear(); int userSelection = -1; bool validSelection = false; Console.Clear(); while (validSelection == false) { Console.WriteLine("Please enter the number next to which Gas Type you would like to fuel your car with"); printGasTypeSelectionOptions(); string stringUserSelection = Console.ReadLine(); validSelection = int.TryParse(stringUserSelection, out userSelection); if (validSelection == true) { if ((eGasType)userSelection != userEngine.GasType) { Console.Clear(); validSelection = false; Console.WriteLine("Wrong Fuel Type!"); Console.WriteLine("Your car can only take {0} ", userEngine.GasType.ToString()); } } if (validSelection == false) { Console.WriteLine("Please try again! "); } } validSelection = false; float fuelUserSelection = -1; Console.Clear(); while (validSelection == false) { Console.WriteLine("Please enter How much fuel you would like to fuel"); string stringUserSelection = Console.ReadLine(); validSelection = float.TryParse(stringUserSelection, out fuelUserSelection); if (validSelection == true) { if (fuelUserSelection + userEngine.GasGague > userEngine.GasCapacity) { validSelection = false; Console.WriteLine("Too much Fuel! "); Console.WriteLine("Your car can only take {0} more Fuel", userEngine.GasCapacity - userEngine.GasGague); } } if (validSelection == false) { Console.WriteLine("Please try again! "); } } Console.Clear(); return(fuelUserSelection); }
public void GasEngine_Set_Get(uint a) { GasEngine _suut = new GasEngine(a); MotorBike _uut = new MotorBike(_suut); Assert.That(_suut.CurThrottle = a, Is.EqualTo(a)); _uut.RunAtHalfSpeed(); Assert.That(_suut.CurThrottle, Is.EqualTo(a / 2)); }
private void receiveFuelInputAndRefuelVehicle(GasEngine i_Engine) { Console.Write( @"Gas Type 1 Soler 2 Octan95 3 Octan96 4 Octan98 Please select gas type: "); bool isValidGasType = false; do { try { int gasType = Utilities.ReceiveEnumInput <GasEngine.eGasType>(); i_Engine.CheckGasType((GasEngine.eGasType)gasType); isValidGasType = true; } catch (ArgumentException argumentException) { Console.Write("Incompatible gas type selected, this vehicle takes {0}, please try again: ", i_Engine.GasType); } }while(!isValidGasType); bool isValidGasAmount = false; Console.Write( @"Your vehicle has {0}l out of {1}l How much gas would you like to add? ", i_Engine.CurrentEnergy, i_Engine.MaxEnergyCapacity); do { try { string amountOfGasInput = Console.ReadLine(); float amountOfGasToAdd = float.Parse(amountOfGasInput); i_Engine.AddEnergy(amountOfGasToAdd); isValidGasAmount = true; } catch (ArgumentException argumentException) { Console.Write("You must enter a positive number, please try again: "); } catch (FormatException formatException) { Console.Write("You must enter a number, please try again: "); } catch (ValueOutOfRangeException valueOutOfRangeException) { Console.Write("That is too much gas, please try again: "); } }while(!isValidGasAmount); }
static void Main(string[] args) { IEngine eng1 = new GasEngine(20); IEngine eng2 = new DieselEngine(50); Motorbike m = new Motorbike(eng1); Motorbike m2 = new Motorbike(eng2); m.RunAtHalfSpeed(); m2.RunAtHalfSpeed(); }
static void Main(string[] args) { System.Console.WriteLine("::::::::GasEngine::::::::"); IEngine myGasEngine = new GasEngine(10); MotorBike myGasBike = new MotorBike(myGasEngine); System.Console.WriteLine("Run at half speed."); myGasBike.RunAtHalfSpeed(); System.Console.WriteLine("::::::::DieselEngine:::::"); IEngine myDieEngine = new DieselEngine(20); MotorBike myDieselBike = new MotorBike(myDieEngine); System.Console.WriteLine("Run at half speed."); myDieselBike.RunAtHalfSpeed(); }
static void Main(string[] args) { // ************************************** // // *** Gas engine and gas-driven bike *** // // ************************************** // var myGasEngine = new GasEngine(100); var myGasMotorBike = new MotorBike(myGasEngine); var thr = myGasEngine.CurThrottle; Console.WriteLine($"My gas throttle when idling is: {thr}."); thr = myGasEngine.MaxThrottle; Console.WriteLine($"My gas throttle at full speed is: {thr}"); myGasMotorBike.RunAtHalfSpeed(); thr = myGasEngine.CurThrottle; Console.WriteLine($"My gas throttle at half speed is: {thr}"); // ******************************************** // // *** Diesel engine and diesel-driven bike *** // // ******************************************** // var myDieselEngine = new DieselEngine(120); var myDieselMotorBike = new MotorBike(myDieselEngine); // Diesel-bike outputs: var thr2 = myDieselEngine.CurThrottle; Console.WriteLine($"My diesel throttle when idling is: {thr2}"); thr2 = myDieselEngine.MaxThrottle; Console.WriteLine($"My diesel throttle at full speed is: {thr2}"); myDieselMotorBike.RunAtHalfSpeed(); thr2 = myDieselEngine.CurThrottle; Console.WriteLine($"My diesel throttle at half speed is: {thr2}"); // ************************************************ // // *** Electric engine and electric-driven bike *** // // ************************************************ // var myElectricEngine = new ElectricEngine(168); var myElectricMotorBike = new MotorBike(myElectricEngine); // Electric-bike outputs: var thr3 = myElectricEngine.CurThrottle; Console.WriteLine($"My electric throttle when idling is: {thr3}"); thr3 = myElectricEngine.MaxThrottle; Console.WriteLine($"My electric throttle at full speed is: {thr3}"); myElectricMotorBike.RunAtHalfSpeed(); thr3 = myElectricEngine.CurThrottle; Console.WriteLine($"My electric throttle at half speed is: {thr3}"); Console.ReadLine(); }
private static Engine createEngine( Engine.eEngineType i_EngineType, float i_MaxCapacity, GasEngine.eGasType?i_GasType = null) { Engine engine = null; if (i_EngineType == Engine.eEngineType.Electric) { engine = new ElectricEngine(i_MaxCapacity); } else { engine = new GasEngine(i_MaxCapacity, (GasEngine.eGasType)i_GasType); } return(engine); }
public static float GetAmountOfFuelFromUser(GasEngine i_EngineToRefuel) { bool isValid = false; float amountOfFuel = 0; while (isValid == false) { Console.WriteLine("Please enter amount of fuel to add"); amountOfFuel = GetFloatFromUser(); isValid = i_EngineToRefuel.IsAmountsOfSourcePowerMaterialValid(amountOfFuel); if (isValid == false) { Console.WriteLine( "Cannot add fuel more than the gas tank can hold, max value: {0}L", i_EngineToRefuel.GetAmountOfSourcePowerMaterialPossible().ToString()); } } return(amountOfFuel); }
static void Main(string[] args) { IEngine engine = new GasEngine(2); MotorBike myBike = new MotorBike(engine); }