Exemplo n.º 1
0
        /// <summary>
        /// Template for a Car method. (same as car values besides the enum for doors)
        /// </summary>
        public static Car CreateNewCar(float currentAmount, E_EngineType engineType, E_Color color, E_NumOfDoors numOfDoors, string vehicleModel,
                                       string vehicleLicensePlate, string ownerName, string ownerPhone, string wheelManufacturerName)
        {
            Engine engine;

            ///switch statment to choose between two types of engine (Fuel/Electric) or invalid value exception in case of unknown value.
            switch (engineType)
            {
            case E_EngineType.Fuel:
                engine = EngineFactory.CreateNewEngine(E_FuelType.Octan98, 50.0f, currentAmount);
                break;

            case E_EngineType.Electric:
                engine = EngineFactory.CreateNewEngine(2.8f, currentAmount);
                break;

            default:
                throw new ArgumentException("Invalid Type");
            }
            ///create the Car object itself.
            Car car = new Car(color, numOfDoors, E_VehicleType.Car, vehicleModel, vehicleLicensePlate,
                              ownerName, ownerPhone, E_VehicleStateInGarage.InWork, wheelManufacturerName, engine);

            return(car);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Template for a Motorcycle
        /// </summary>
        /// <param name="currentAmount">float value</param>
        /// <param name="engineType">enum value</param>
        /// <param name="licenseType">enum value</param>
        /// <param name="engineVolume">int value</param>
        /// <param name="vehicleModel">string value</param>
        /// <param name="vehicleLicensePlate">string value</param>
        /// <param name="ownerName">string value</param>
        /// <param name="ownerPhone">string value</param>
        /// <param name="wheelManufacturerName">string value</param>
        /// <returns></returns>
        public static Motorcycle CreateNewMotorcycle(float currentAmount, E_EngineType engineType, E_LicenseType licenseType, int engineVolume,
                                                     string vehicleModel, string vehicleLicensePlate, string ownerName, string ownerPhone, string wheelManufacturerName)
        {
            ///create a new show of engine for Motorcycle
            Engine engine;

            ///switch statment to choose between two types of engine (Fuel/Electric) or invalid value exception in case of unknown value.
            switch (engineType)
            {
            case E_EngineType.Fuel:
                engine = EngineFactory.CreateNewEngine(1.6f, currentAmount);
                break;

            case E_EngineType.Electric:
                engine = EngineFactory.CreateNewEngine(E_FuelType.Octan95, 5.5f, currentAmount);
                break;

            default:
                throw new ArgumentException("Invalid Type");
            }
            ///create the Motorcycle object itself.
            Motorcycle motorcycle = new Motorcycle(licenseType, engineVolume,
                                                   E_VehicleType.Bike, vehicleModel, vehicleLicensePlate, ownerName, ownerPhone,
                                                   E_VehicleStateInGarage.InWork, wheelManufacturerName, engine);

            return(motorcycle);
        }
Exemplo n.º 3
0
 /// <summary>
 /// add a new bike method
 /// </summary>
 /// <param name="engineType">enum type value</param>
 private static void addNewBike(E_EngineType engineType)
 {
     try
     {
         E_LicenseType licenseType  = Utils.Parsers.ParseLicenseType();
         int           engineVolume = Utils.Parsers.GetIntFromUser("Enter engine volume in cc:");
         float         currentAmount;
         string        vehicleModel;
         string        licensePlate;
         string        ownerName;
         string        ownerPhone;
         string        wheelManufacturerName;
         Utils.Parsers.RefBasicVehicleDetails(out currentAmount, out vehicleModel, out licensePlate,
                                              out ownerName, out ownerPhone, out wheelManufacturerName);
         GarageLogic.GarageLogic.GarageDirectory.Add(licensePlate, VehicleFactory.CreateNewMotorcycle(currentAmount, engineType,
                                                                                                      licenseType, engineVolume, vehicleModel, licensePlate, ownerName, ownerPhone, wheelManufacturerName));
     }
     catch (FormatException ex)
     {
         Console.WriteLine(ex.Message + "Can`t parse Motorcycle!");
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// add a new car method
 /// </summary>
 /// <param name="engineType">enum value of engine type</param>
 private static void addNewCar(E_EngineType engineType)
 {
     try
     {
         E_Color      color      = Utils.Parsers.ParseCarColor();
         E_NumOfDoors numOfDoors = Utils.Parsers.ParseNumOfCarDoors();
         float        currentAmount;
         string       vehicleModel;
         string       vehicleLicensePlate;
         string       ownerName;
         string       ownerPhone;
         string       wheelManufacturerName;
         Utils.Parsers.RefBasicVehicleDetails(out currentAmount, out vehicleModel, out vehicleLicensePlate,
                                              out ownerName, out ownerPhone, out wheelManufacturerName);
         GarageLogic.GarageLogic.GarageDirectory.Add(vehicleLicensePlate, VehicleFactory.CreateNewCar
                                                         (currentAmount, engineType, color, numOfDoors, vehicleModel, vehicleLicensePlate, ownerName, ownerPhone, wheelManufacturerName));
     }
     catch (FormatException ex)
     {
         Console.WriteLine(ex.Message + "Can`t parse Car!");
     }
 }