예제 #1
0
        /// <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);
            }
        }
예제 #2
0
파일: Vehicle.cs 프로젝트: benshaty/Garage
        /// <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;
        }
예제 #3
0
파일: Truck.cs 프로젝트: benshaty/Garage
 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;
 }
예제 #4
0
 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;
 }
예제 #5
0
파일: Car.cs 프로젝트: benshaty/Garage
 /// <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;
 }
예제 #6
0
 /// <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());
     }
 }
예제 #7
0
        /// <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);
        }
예제 #8
0
 /// <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;
 }