/// <summary> /// change the car state in the garage method /// </summary> private static void changeCarState() { string licensePlate = getLicensePlateFromUser(); E_VehicleStateInGarage vehicleState = getVehicleStateFromUser(); try { Vehicle vehicle = GarageLogic.GarageLogic.GetVehicleByLicensePlate(licensePlate); GarageLogic.GarageLogic.ChangeVehicleStateInGarage(vehicle, vehicleState); Console.WriteLine($"{vehicle.VehicleType} changed status to {vehicle.VehicleStateInGarage}"); } catch (KeyNotFoundException) { Console.WriteLine("Vehicle is not in garage"); Console.WriteLine("Do you want to put vehicle in the garage?"); string answer = Console.ReadLine(); if (answer.StartsWith("y") || answer.StartsWith("Y")) { addAVehicle(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// This is the Vehicle object created /// </summary> /// <param name="vehicleType"></param> /// <param name="vehicleModel"></param> /// <param name="vehicleLicensePlate"></param> /// <param name="ownerName"></param> /// <param name="ownerPhone"></param> /// <param name="vehicleState"></param> /// <param name="wheelManufacturerName"></param> /// <param name="vehicleEngine"></param> public Vehicle(E_VehicleType vehicleType, string vehicleModel, string vehicleLicensePlate, string ownerName, string ownerPhone, E_VehicleStateInGarage vehicleState, string wheelManufacturerName, Engine vehicleEngine) { float maxAirPresureByVehicleType; VehicleLicensePlate = vehicleLicensePlate; OwnerName = ownerName; OwnerPhone = ownerPhone; VehicleStateInGarage = vehicleState; VehicleEngine = vehicleEngine; VehicleModel = vehicleModel; ///switch between the Vehicle possible types (Car/Bike/Truck) switch (vehicleType) { case E_VehicleType.Bike: maxAirPresureByVehicleType = 28.0f; break; case E_VehicleType.Car: maxAirPresureByVehicleType = 32.0f; break; case E_VehicleType.Truck: maxAirPresureByVehicleType = 34.0f; break; default: throw new ArgumentException("Invalid vehicle type"); } ///create a new show of vehicle wheels object . VehicleWheels = new Wheel(wheelManufacturerName, maxAirPresureByVehicleType); VehicleEngine = vehicleEngine; }
public Truck(bool hezerdosMat, float maxWeight, E_VehicleType vehicleType, string vehicleModel, string vehicleLicensePlate, string ownerName, string OwnerPhone, E_VehicleStateInGarage vehicleState, string wheelManufacturerName, Engine vehicleEngine) : base(vehicleType, vehicleModel, vehicleLicensePlate, ownerName, OwnerPhone, vehicleState, wheelManufacturerName, vehicleEngine) { HazardousMaterials = hezerdosMat; MaxWeight = maxWeight; NumOfWheels = E_NumOfWheels.Four; }
public Motorcycle(E_LicenseType licenseType, int engineVolume, E_VehicleType vehicleType, string vehicleModel, string vehicleLicensePlate, string ownerName, string OwnerPhone, E_VehicleStateInGarage vehicleState, string wheelManufacturerName, Engine vehicleEngine) : base(vehicleType, vehicleModel, vehicleLicensePlate, ownerName, OwnerPhone, vehicleState, wheelManufacturerName, vehicleEngine) { LicenseType = licenseType; EngineVolume = engineVolume; NumOfWheels = E_NumOfWheels.Two; }
/// <summary> /// this is the car full details /// </summary> /// <param name="carColor"></param> /// <param name="carNumOfDoors"></param> /// <param name="vehicleType"></param> /// <param name="vehicleModel"></param> /// <param name="vehicleLicensePlate"></param> /// <param name="ownerName"></param> /// <param name="OwnerPhone"></param> /// <param name="vehicleState"></param> /// <param name="wheelManufacturerName"></param> /// <param name="vehicleEngine"></param> public Car(E_Color carColor, E_NumOfDoors carNumOfDoors, E_VehicleType vehicleType, string vehicleModel, string vehicleLicensePlate, string ownerName, string OwnerPhone, E_VehicleStateInGarage vehicleState, string wheelManufacturerName, Engine vehicleEngine) : base(vehicleType, vehicleModel, vehicleLicensePlate, ownerName, OwnerPhone, vehicleState, wheelManufacturerName, vehicleEngine) { Color = carColor; Doors = carNumOfDoors; NumOfWheels = E_NumOfWheels.Four; }
/// <summary> /// showing car by entering license plate value. /// </summary> /// <param name="state"></param> private static void showCarsByLicencePlate(E_VehicleStateInGarage state) { foreach (var item in GarageLogic.GarageLogic.GarageDirectory) { if (item.Value.VehicleStateInGarage == state) { Console.WriteLine($"License plate {item.Key}:"); } Console.WriteLine("============================================="); Console.WriteLine(item.Value.ToString()); } }
/// <summary> /// getting the vehicle state in the garage method /// </summary> /// <returns></returns> private static E_VehicleStateInGarage getVehicleStateFromUser() { E_VehicleStateInGarage userResponse = E_VehicleStateInGarage.NotInGarage; try { userResponse = Utils.Parsers.ParseStateInGarage(); } catch (FormatException ex) { Console.WriteLine(ex.Message); userResponse = Utils.Parsers.ParseStateInGarage(); } return(userResponse); }
/// <summary> /// Method to change the state of vehicle in the garage. /// </summary> /// <param name="vehicleToChange">inserting vehicleToChange attribute value</param> /// <param name="VehicleStateInGarage">enum value</param> public static void ChangeVehicleStateInGarage(Vehicle vehicleToChange, E_VehicleStateInGarage VehicleStateInGarage) { vehicleToChange.VehicleStateInGarage = VehicleStateInGarage; }