public AmountCarDoors GetAmountOfDoorsFromUser() { Console.WriteLine("Select the amount of doors in your car:"); Console.WriteLine("[1] Two"); Console.WriteLine("[2]Three"); Console.WriteLine("[3]Four"); Console.WriteLine("[4]Five"); AmountCarDoors amount = (AmountCarDoors)Enum.Parse(typeof(AmountCarDoors), Console.ReadLine()); return(amount); }
//Amount of doors: public override AmountCarDoors SetAmountOfDoors(int input) { amount_of_car_doors = (AmountCarDoors)input; return(amount_of_car_doors); }
//amount of doors public virtual AmountCarDoors SetAmountOfDoors(int input) { amountCarDoors = (AmountCarDoors)input; return(amountCarDoors); }
public void InformationSorter(Vehicle vehicle) { string License_P = vehicle.GetLicensePlate(); Vehicle.VehicleType vhicle_T = vehicle.GetTypeOfVehicle(); Console.WriteLine("============================================================"); Console.WriteLine("Vehicle Full Information:"); Console.WriteLine("Vehicle License Plate:{0}", License_P); Console.WriteLine("Vehicle Type:{0}", vhicle_T); if (vhicle_T == (Vehicle.VehicleType) 1) { AmountCarDoors amount_ocd = vehicle.GetAmountOfDoors(); Color c = vehicle.GetColor(); Console.WriteLine("Amount of doors: {0}", amount_ocd); Console.WriteLine("Color: {0}", c); } if (vhicle_T == (Vehicle.VehicleType) 2) { bool is_carring_Dangerous_Subs = vehicle.GetDangerousSubstance(); float Max_Cargo_Weight = vehicle.GetMaxCargoWeight(); Console.WriteLine("Is carring dangerous Substance: {0}", is_carring_Dangerous_Subs); Console.WriteLine("Max cargo weight: {0}", Max_Cargo_Weight); } if (vhicle_T == (Vehicle.VehicleType) 3) { int Engine_V = vehicle.GetEngineVolume(); LicenseType License_T = vehicle.GetLicenseType(); Console.WriteLine("Engine volume: {0}", Engine_V); Console.WriteLine("License type: {0}", License_T); } Console.WriteLine("Model: {0}", vehicle.GetModel()); Console.WriteLine("Current PSI: {0}", vehicle.GetCurrentPSI()); if (vehicle.GetEngineType() == (Engine)1) { float Current_Amount_Of_E = vehicle.GetCurrentAmountOfEnergy(); Console.WriteLine("Engine Type: {0}", vehicle.GetEngineType()); Console.WriteLine("Current amount of energy: {0}", Current_Amount_Of_E); } if (vehicle.GetEngineType() == (Engine)2) { float Current_Amount_Of_F = vehicle.GetCurrentAmountOfFuel(); GasType Gas_T = vehicle.GetGasType(); Console.WriteLine("Engine Type: {0}", vehicle.GetEngineType()); Console.WriteLine("Current amount of Fuel: {0}", Current_Amount_Of_F); Console.WriteLine("Fuel Type: {0}", Gas_T); } int tires = vehicle.typeOfTire; if (tires == 1) { Console.WriteLine("Type of tires:{0} Manufacturer is: Michelin ", tires); } if (tires == 2) { Console.WriteLine("Type of tires:{0} Manufacturer is: Pirelli ", tires); } if (tires == 3) { Console.WriteLine("Type of tires:{0} Manufacturer is: Dunlop", tires); } if (tires == 4) { Console.WriteLine("Type of tires:{0} Manufacturer is: GoodYear ", tires); } if (tires == 5) { Console.WriteLine("Type of tires:{0} Manufacturer is: Kumho ", tires); } if (tires == 6) { Console.WriteLine("Type of tires:{0} Manufacturer is: Hankook ", tires); } Console.WriteLine("============================================================"); }
//Vehicle Creator ->Contacts factory ->Creates Vehicle->Adds it to GarageList. public Vehicle GetVehicleDetails(string License_plate) { float amountOfEnergy = 0; GasType Gas_type = 0; float amountOfGas = 0; Color color = 0; AmountCarDoors amount = 0; bool isCarringDangerous = true; float MaximumCarryWeight = 0; int typeOfTires = 0; LicenseType type = 0; int EngineCapacity = 0; string model; Console.WriteLine("Enter owners name:"); string owner_name = GetFromUserName(); Console.WriteLine("Enter owners phone:"); string owner_phone = GetFromUserPhone(); Vehicle.VehicleType Vehicle_type = GetFromUserVehicleType(); model = GetFromUserModel(); //Acumilating details depends on the engine type selected. Engine Engine_type = GetFromUserEngineType(); if (Engine_type == (Engine)2)//fuel info { Gas_type = GetFromUserGasType(); amountOfGas = GetCurrentAmountOfGas(); } if (Engine_type == (Engine)1)//electric info { amountOfEnergy = GetCurrentAmountOfEnergy(); } //Acumilating details depending on the vehicle type selected if (Vehicle_type == (Vehicle.VehicleType) 1) //car { color = GetCarColorFromUser(); amount = GetAmountOfDoorsFromUser(); typeOfTires = GetTypeOfTire(); } if (Vehicle_type == (Vehicle.VehicleType) 2) //truck { isCarringDangerous = IsCarringDangerousSubstance(); MaximumCarryWeight = GetMaximumCarryWeight(); typeOfTires = GetTypeOfTire(); } if (Vehicle_type == (Vehicle.VehicleType) 3)//motorcycle { type = GetLicenseType(); EngineCapacity = GetEngineVolume(); typeOfTires = GetTypeOfTire(); } //addressing the factory with the request to create a vehicle with the specifications. if (Engine_type == (Engine)1) { var vehicle = GarageManage.StartElectricAssembly(Engine_type, License_plate, owner_name, owner_phone, model, amountOfEnergy, Vehicle_type, typeOfTires, type, EngineCapacity, isCarringDangerous, MaximumCarryWeight, color, amount); return(vehicle); } if (Engine_type == (Engine)2) { var vehicle = GarageManage.StartFuelAssembly(Engine_type, License_plate, owner_name, owner_phone, model, amountOfGas, Vehicle_type, typeOfTires, type, EngineCapacity, isCarringDangerous, MaximumCarryWeight, color, amount); return(vehicle); } return(null); }
//assemblieng electric vehicles: public static Vehicle ElectricAssemblyLine(Engine Engine_type, string License_plate, string owner_name, string owner_phone, string model, float amountOfEnergy, VehicleType Vehicle_type, int typeOfTires, LicenseType type, int EngineCapacity, bool IsCarringDangerous, float MaxCarryWeight, Color color, AmountCarDoors amount) { if (Vehicle_type == (VehicleType)1) { var vehicle = CreateElectricCar(Engine_type, License_plate, owner_name, owner_phone, amountOfEnergy); CarSpecifics(vehicle, typeOfTires, color, amount); return(vehicle); } if (Vehicle_type == (VehicleType)2) { var vehicle = CreateElectricTruck(Engine_type, License_plate, owner_name, owner_phone, amountOfEnergy); TruckSpecifics(vehicle, typeOfTires, IsCarringDangerous, MaxCarryWeight); return(vehicle); } if (Vehicle_type == (VehicleType)3) { var vehicle = CreateElectricMotorcycle(Engine_type, License_plate, owner_name, owner_phone, amountOfEnergy); MotorcycleSpecifics(vehicle, typeOfTires, type, EngineCapacity); return(vehicle); } return(null); }
//vehicles specifics: public static void CarSpecifics(Vehicle vehicle, int typeOfTires, Color color, AmountCarDoors amount) { vehicle.SetColor((int)color); vehicle.SetAmountOfDoors((int)amount); vehicle.SetTypeOfTires(typeOfTires); }
public static Vehicle StartFuelAssembly(Engine Engine_type, string License_plate, string owner_name, string owner_phone, string model, float amountOfGas, VehicleType Vehicle_type, int typeOfTires, LicenseType type, int EngineCapacity, bool IsCarringDangerous, float MaxCarryWeight, Color color, AmountCarDoors amount) { var vehicle = Factory.FuelAssemblyLine(Engine_type, License_plate, owner_name, owner_phone, model, amountOfGas, Vehicle_type, typeOfTires, type, EngineCapacity, IsCarringDangerous, MaxCarryWeight, color, amount); return(vehicle); }