Пример #1
0
        // $G$ DSN-002 (-10) The UI should not know Car\Truck\Motorcycle
        private void insertCar()
        {
            string modelName     = getModelName();
            string licenseNumber = getLicenseNumber();

            Factory.eEnergyType energyType    = GetEnergyType();
            EnergyStorage       energyStorage = Factory.GenerateEnergyStorage(Factory.eVehicleType.Car, energyType);
            float       energyPercentage      = getEnergyPercentage();
            List <Tire> wheels        = insertWheels(Factory.eVehicleType.Car, k_CarWheelsAmount);
            byte        numberOfDoors = getNumberOfDoors();

            Car.eColor color = getCarColor();

            Car car = Factory.GenerateCar(modelName, licenseNumber, wheels, energyStorage, color, numberOfDoors, energyPercentage);

            try
            {
                r_GarageLogic.InsertVehicleToGarage(getOwnerDetails(car));
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex.Message);
                Console.ResetColor();
            }
        }
 public CarThatOperatesOnFuel(string i_NameOfModel, string i_NumberOfLicense, string i_NameOfWheelManufacturer,
                              float i_RemainingAmountOfFuelInTheTank,
                              Car.eColor i_Color, byte i_NumberOfDoors)
     : base(i_NameOfModel, i_NumberOfLicense, k_NumberOfWheels, i_NameOfWheelManufacturer, k_MaximumWheelAirPressure, k_TypeOfFuel, i_RemainingAmountOfFuelInTheTank, k_CapacityOfTank)
 {
     m_car = new Car(i_Color, i_NumberOfDoors);
 }
Пример #3
0
 public ElectricCar(string i_NameOfModel, string i_NumberOfLicense, string i_NameOfWheelManufacturer,
                    float i_RemainingNumberOfHoursForLifeTimeOfBattery,
                    Car.eColor i_Color, byte i_NumberOfDoors)
     : base(i_NameOfModel, i_NumberOfLicense, k_NumberOfWheels, i_NameOfWheelManufacturer, k_MaximumWheelAirPressure, i_RemainingNumberOfHoursForLifeTimeOfBattery, k_MaximumNumberOfHoursForLifeTimeOfBattery)
 {
     m_car = new Car(i_Color, i_NumberOfDoors);
 }
        private static Vehicles CreateElectricCarObject()
        {
            float  PercentageOfEnergyRemainingInItsEnergysource = 0, BatteryTimeremainingInhours = 0, CurrentAirPressur = 0;
            string LicenseNumber = "", ModelName = "", WheelManufacturerName = "";
            int    AmountOfDoors = 0;

            Car.eColor ColorOfCar = 0;
            Vehicles   NewElectricCarObject;

            GetNewVehiclePharameter(ref LicenseNumber, ref ModelName,
                                    ref PercentageOfEnergyRemainingInItsEnergysource, ref CurrentAirPressur, ref WheelManufacturerName);

            if (CurrentAirPressur > Car.CarWheelsMaxAirPressure || CurrentAirPressur < 0)
            {
                throw new ValueOutOfRangeException(Car.CarWheelsMaxAirPressure, 0);
            }

            GetCarPharameter(ref ColorOfCar, ref AmountOfDoors);

            GetElectricVehiclesPharameter(ref BatteryTimeremainingInhours);

            if (BatteryTimeremainingInhours > ElectricCar.MaximumBatteryInHours || BatteryTimeremainingInhours < 0)
            {
                throw new ValueOutOfRangeException(ElectricCar.MaximumBatteryInHours, 0);
            }

            NewElectricCarObject = CreatNewObject.CreatElectricCar(AmountOfDoors, BatteryTimeremainingInhours, ColorOfCar
                                                                   , ModelName, LicenseNumber,
                                                                   PercentageOfEnergyRemainingInItsEnergysource, CurrentAirPressur, WheelManufacturerName);

            return(NewElectricCarObject);
        }
        private static Vehicles CreateGasCarObject()
        {
            float  PercentageOfEnergyRemainingInItsEnergysource = 0, FuelPresentInLiters = 0, CurrentAirPressur = 0;
            string LicenseNumber = "", ModelName = "", WheelManufacturerName = "";

            Car.eColor ColorOfCar = 0;
            int        AmountOfDoors = 0;
            Vehicles   NewGasCar;

            GetNewVehiclePharameter(ref LicenseNumber, ref ModelName, ref PercentageOfEnergyRemainingInItsEnergysource, ref CurrentAirPressur, ref WheelManufacturerName);
            if (CurrentAirPressur > Car.CarWheelsMaxAirPressure || CurrentAirPressur < 0)
            {
                throw new ValueOutOfRangeException(Car.CarWheelsMaxAirPressure, 0);
            }

            GetGasVehiclesPharameter(ref FuelPresentInLiters);

            if (FuelPresentInLiters > CarWorkingOnGas.MaximumAmountOfFuelInLiters || FuelPresentInLiters < 0)
            {
                throw new ValueOutOfRangeException(CarWorkingOnGas.MaximumAmountOfFuelInLiters, 0);
            }

            GetCarPharameter(ref ColorOfCar, ref AmountOfDoors);
            NewGasCar = CreatNewObject.CreatGasCar(AmountOfDoors, FuelPresentInLiters, ColorOfCar
                                                   , ModelName, LicenseNumber,
                                                   PercentageOfEnergyRemainingInItsEnergysource, CurrentAirPressur, WheelManufacturerName);

            return(NewGasCar);
        }
Пример #6
0
        private static Car createACar(string i_Module,
                                      string i_VehicleLicense, float i_CurrentPowerInPowerSource, List <string> i_Wheels,
                                      Dictionary <string, string> i_VehicleDetails, e_TypeOfPowerSource i_PowerSource)
        {
            PowerSource powerSource;

            if (i_PowerSource.Equals(e_TypeOfPowerSource.Battery))
            {
                powerSource = new Battery(2.5f, i_CurrentPowerInPowerSource);
            }

            else
            {
                powerSource = new FuelTank(42f, i_CurrentPowerInPowerSource, PowerSource.eFuel.Octan98);
            }

            string colorValue;

            i_VehicleDetails.TryGetValue("color", out colorValue);
            string numberOfDoorsValue;

            i_VehicleDetails.TryGetValue("numberOfDoors", out numberOfDoorsValue);
            Car.eColor         color         = (Car.eColor)(Enum.Parse(typeof(Car.eColor), colorValue));
            Car.eNumberOfDoors numberOfDoors = (Car.eNumberOfDoors)(Enum.Parse(typeof(Car.eNumberOfDoors), numberOfDoorsValue));
            List <Wheel>       wheels        = generateWheels(4, 30, i_Wheels[0], i_Wheels[1]);

            return(new Car(i_Module, i_VehicleLicense, color, numberOfDoors, wheels, powerSource));
        }
        private void InitializeCar()
        {
            Car.eColor      Color      = UserCommunicator.ToCarColor(UserCommunicator.getStringThatEqualsOneOf("What color is your car", new string[] { "Grey", "Blue", "White", "Black" }, false));
            Car.eNumOfDoors NumOfDoors = UserCommunicator.ToNumOfDoors(UserCommunicator.getIntInRange("How many doors your car have?", 2, 5));

            m_DataBase.m_Color      = Color;
            m_DataBase.m_NumOfDoors = NumOfDoors;
        }
Пример #8
0
        public static FuelBasedCar CreateFuelCar(VehicleInformation i_vehicleInformation, Dictionary <string, Object> i_specificInformation)
        {
            Car.eColor            color      = (Car.eColor)i_specificInformation["Color"];
            Car.eCarNumberOfDoors numOfDoors = (Car.eCarNumberOfDoors)i_specificInformation["Number Of Doors"];
            string       wheelManufacturer   = (string)i_specificInformation["Wheel Manufacturer"];
            FuelBasedCar fuelCar             = new FuelBasedCar(color, numOfDoors, i_vehicleInformation, wheelManufacturer);

            return(fuelCar);
        }
Пример #9
0
 internal Car(Car.eColor i_color, byte i_NumberOfDoors)
 {
     if (i_NumberOfDoors < k_MinimumNumberOfDoors || i_NumberOfDoors > k_MaximumNumberOfDoors)
     {
         throw new ValueOutOfRangeException("i_NumberOfDoors", i_NumberOfDoors, k_MinimumNumberOfDoors, k_MaximumNumberOfDoors);
     }
     m_color         = i_color;
     m_NumberOfDoors = i_NumberOfDoors;
 }
Пример #10
0
        private void insertColor(Car i_NewCar)
        {
            int color;

            Car.eColor colorOptions           = new Car.eColor();
            string     PartOfOptionsHeaderMsg = string.Format("car's color");

            color          = UI.GetSpecificEnumInput(PartOfOptionsHeaderMsg, colorOptions);
            i_NewCar.Color = (Car.eColor)color;
        }
Пример #11
0
        private void insertColorForCar(Car i_NewCar)
        {
            int color;

            Car.eColor colorOptions           = new Car.eColor();
            string     PartOfOptionsHeaderMsg = string.Format("car's color");

            color          = m_InputUI.MakeArrayOfStringFromEnum(PartOfOptionsHeaderMsg, colorOptions);
            i_NewCar.Color = (Car.eColor)color;
        }
        public CarThatOperatesOnFuel(string i_NameOfModel, string i_NumberOfLicense, string i_NameOfWheelManufacturer, float[] i_WheelsAirPressures,
                                     Car.eColor i_Color, byte i_NumberOfDoors)
            : base(i_NameOfModel, i_NumberOfLicense, i_WheelsAirPressures, i_NameOfWheelManufacturer, k_MaximumWheelAirPressure, k_TypeOfFuel, k_CapacityOfTank)
        {
            if (i_WheelsAirPressures.Length != k_NumberOfWheels)
            {
                throw new ArgumentException("i_WheelsAirPressures.Length must be equal to " + k_NumberOfWheels + '.', "i_WheelsAirPressures.Length");
            }

            m_car = new Car(i_Color, i_NumberOfDoors);
        }
Пример #13
0
 public static Car GenerateCar(
     string i_ModelName,
     string i_LicenseNumber,
     List <Tire> i_Wheels,
     EnergyStorage i_EnergyStorage,
     Car.eColor i_Color,
     byte i_NumberOfDoors,
     float i_EnergyPercentage)
 {
     return(new Car(i_Color, i_NumberOfDoors, i_EnergyStorage, i_ModelName, i_LicenseNumber, i_Wheels, i_EnergyPercentage));
 }
Пример #14
0
        public ElectricCar(string i_NameOfModel, string i_NumberOfLicense, string i_NameOfWheelManufacturer, float[] i_WheelsAirPressures,
                           Car.eColor i_Color, byte i_NumberOfDoors)
            : base(i_NameOfModel, i_NumberOfLicense, i_WheelsAirPressures, i_NameOfWheelManufacturer, k_MaximumWheelAirPressure, k_MaximumNumberOfHoursForLifeTimeOfBattery)
        {
            if (i_WheelsAirPressures.Length != k_NumberOfWheels)
            {
                throw new ArgumentException("i_WheelsAirPressures.Length must be equal to " + k_NumberOfWheels + '.', "i_WheelsAirPressures.Length");
            }

            m_car = new Car(i_Color, i_NumberOfDoors);
        }
        private Vehicle addElectricCar(string i_LicenseNumber, string i_Model, string i_ManufacturerName, float i_MaxAirPressure)
        {
            string electricCarData =
                @"Please enter the following additional information: 
1. Car color (Grey,Blue,White,Black)
2. numberOfDoors(Two,Three,Four,Five)";

            Console.WriteLine(electricCarData);
            Car.eColor      color         = (Car.eColor)Enum.Parse(typeof(Car.eColor), Console.ReadLine());
            Car.eNumOfDoors numberOfDoors = (Car.eNumOfDoors)Enum.Parse(typeof(Car.eNumOfDoors), Console.ReadLine());
            return(MakeVehicle.MakeElectricCar(i_Model, i_LicenseNumber, i_ManufacturerName, i_MaxAirPressure, color, numberOfDoors));
        }
Пример #16
0
 public ElectricCar(
     string i_ModelName,
     string i_LicenseNumber,
     string[] i_ManufacturerNamesOfAllTires,
     float[] i_CurrentPressureOfAllTires,
     float i_RemainingBatteryTime,
     Car.eDoorCount i_DoorsAmount,
     Car.eColor i_Color) : base(
         i_ModelName,
         i_LicenseNumber,
         i_RemainingBatteryTime / k_MaxBatteryTime,
         k_VehicleType,
         i_ManufacturerNamesOfAllTires,
         i_CurrentPressureOfAllTires,
         i_RemainingBatteryTime,
         k_MaxBatteryTime)
 {
     m_ElectricCar = new Car(i_DoorsAmount, i_Color);
 }
Пример #17
0
        public static Vehicle CreateNewElectricCar(
            string i_ModelName,
            string i_LicenseNumber,
            string[] i_ManufacturerNamesOfAllTires,
            float[] i_CurrentPressureOfAllTires,
            float i_RemainingBatteryTime,
            Car.eDoorCount i_DoorsAmount,
            Car.eColor i_Color)
        {
            Vehicle vehicle = new ElectricCar(
                i_ModelName,
                i_LicenseNumber,
                i_ManufacturerNamesOfAllTires,
                i_CurrentPressureOfAllTires,
                i_RemainingBatteryTime,
                i_DoorsAmount,
                i_Color);

            return(vehicle);
        }
        private static void GetCarPharameter(ref Car.eColor io_ColorOfVehicles, ref int io_AmountOfDoors)//קליטת פרמטרים למכונית-v
        {
            string AmountOfDoors;

            io_ColorOfVehicles = SelectColorOfVehicles();

            Console.WriteLine("please enter Amount Of Doors");

            AmountOfDoors = Console.ReadLine();

            if (!int.TryParse(AmountOfDoors, out io_AmountOfDoors))
            {
                throw new FormatException();
            }

            else if (io_AmountOfDoors < 2 || io_AmountOfDoors > 5)
            {
                throw new ValueOutOfRangeException(5, 2);
            }
        }
Пример #19
0
 public PetrolCar(
     string i_ModelName,
     string i_LicenseNumber,
     string[] i_ManufacturerNamesOfAllTires,
     float[] i_CurrentPressureOfAllTires,
     float i_RemainingFuelAmount,
     Car.eDoorCount i_DoorsAmount,
     Car.eColor i_Color) : base(
         i_ModelName,
         i_LicenseNumber,
         i_RemainingFuelAmount / k_MaxFuelTankCapacity,
         k_VehicleType,
         i_ManufacturerNamesOfAllTires,
         i_CurrentPressureOfAllTires,
         k_FuelType,
         k_MaxFuelTankCapacity,
         i_RemainingFuelAmount)
 {
     m_PetrolCar = new Car(i_DoorsAmount, i_Color);
 }
Пример #20
0
        public static Car CreateCar(Car.eColor i_CarColor, Car.eNumbersOfDoors i_NumberOfDoors, string i_ModelName, string i_LicensePlateNumber, Vehicle.eMaximumAirPressure i_MaximumAirPressureForVehicle, List <Wheel> i_CarWheels, Engine i_CarEngine)
        {
            Car newCar = new Car(i_CarColor, i_NumberOfDoors, i_ModelName, i_LicensePlateNumber, i_MaximumAirPressureForVehicle, i_CarWheels, i_CarEngine);

            return(newCar);
        }
Пример #21
0
        public static Car createCar(Car.eColor i_Color, Car.eNumberOfDoors i_NumberOfDoors)
        {
            Car newCar = new Car(i_Color, i_NumberOfDoors);

            return(newCar);
        }
Пример #22
0
 public static Vehicle MakeElectricCar(string i_Model, string i_LicenseNumber, string i_WheelManufacturerName, float i_WheelMaxAirPressure, Car.eColor i_Color, Car.eNumOfDoors i_NumberOfDoors)
 {
     return(new Car(i_Model, i_LicenseNumber, i_WheelManufacturerName, i_WheelMaxAirPressure, i_Color, i_NumberOfDoors, new Battery(k_ElectricCarMaxBattery)));
 }
Пример #23
0
 public static Vehicle MakeRegularCar(string i_Model, string i_LicenseNumber, string i_WheelManufacturerName, float i_WheelMaxAirPressure, Car.eColor i_Color, Car.eNumOfDoors i_NumberOfDoors)
 {
     return(new Car(i_Model, i_LicenseNumber, i_WheelManufacturerName, i_WheelMaxAirPressure, i_Color, i_NumberOfDoors, new GasTank(GasTank.eTypeOfFuel.Octan98, k_RegularCarVolumeGasTank)));
 }
Пример #24
0
        public static Vehicles CreatGasCar(int i_AmountOfDoors, float i_AmountOfFuelPresentInLiters, Car.eColor i_ColorOfCar
                                           , string i_ModelName, string i_LicenseNumber,
                                           float i_PercentageOfEnergyRemainingInItsEnergysource, float i_CurrentAirPressur, String i_WheelManufacturerName)
        {
            CarWorkingOnGas CreatCarWorkingOnGas = new CarWorkingOnGas(i_AmountOfDoors, i_AmountOfFuelPresentInLiters, i_ColorOfCar
                                                                       , i_ModelName, i_LicenseNumber,
                                                                       i_PercentageOfEnergyRemainingInItsEnergysource, i_CurrentAirPressur, i_WheelManufacturerName);

            return(CreatCarWorkingOnGas);
        }
Пример #25
0
        /*** Class Logic ***/

        public void SetCarDoorsAndColor(Car.eColor i_Color, Car.eNumOfDoors i_NumOfDoors)
        {
            m_Color         = i_Color;
            m_NumberOfDoors = i_NumOfDoors;
        }
 public static Vehicle GasCarMaker(Owner i_Owner, string i_Model, string i_LicenceNumber, GasTank i_GasTank, Wheel[] i_Wheels, Car.eColor i_Color, Car.eNumberOfDoors i_NumberOfDoors)
 {
     return(new GasCar(i_Owner, i_Model, i_LicenceNumber, i_GasTank, i_Wheels, i_Color, i_NumberOfDoors));
 }
Пример #27
0
        public static Vehicles CreatElectricCar(int i_AmountOfDoors, float i_BatteryTimeremainingInhours, Car.eColor i_ColorOfCar
                                                , string i_ModelName, string i_LicenseNumber,
                                                float i_PercentageOfEnergyRemainingInItsEnergysource, float i_CurrentAirPressur, String i_WheelManufacturerName)
        {
            ElectricCar NewElectricCar = new ElectricCar(i_AmountOfDoors, i_BatteryTimeremainingInhours, i_ColorOfCar
                                                         , i_ModelName, i_LicenseNumber,
                                                         i_PercentageOfEnergyRemainingInItsEnergysource, i_CurrentAirPressur, i_WheelManufacturerName);

            return(NewElectricCar);
        }
 public static Vehicle ElectronicCarMaker(Owner i_Owner, string i_Model, string i_LicenceNumber, ElectronicTank i_ElectronicTank, Wheel[] i_Wheels, Car.eColor i_Color, Car.eNumberOfDoors i_NumberOfDoors)
 {
     return(new ElectronicCar(i_Owner, i_Model, i_LicenceNumber, i_ElectronicTank, i_Wheels, i_Color, i_NumberOfDoors));
 }
Пример #29
0
        private static void registerVehicle(string i_VehicleLicensePlate, Garage i_Garage)
        {
            string stringUserChoiceForVehicle;
            int    intUserChoiceForVehicle = 0;
            bool   isChoiceValid           = !true;

            CreateVwhicleInGarage.eVehicleTypes typeOfVehicleToAdd;
            string          vehicleOwnersName        = getVehicleOwnersName();
            string          vehicleOwnersPhoneNumber = getVehicleOwnersPhoneNumber();
            string          vehicleModelName         = getVehicleModelName();
            Engine          engineForVehicle;
            List <Wheel>    wheelsForVehicle;
            Vehicle         vehicleToAdd = null;
            VehicleInGarage newVehicleToAddToTheGarage;

            while (isChoiceValid == !true)
            {
                printVehicleMenu();
                stringUserChoiceForVehicle = Console.ReadLine();
                try
                {
                    intUserChoiceForVehicle = convertUserChoiceToInt(stringUserChoiceForVehicle);
                    isChoiceValid           = checkChoiceValidity(intUserChoiceForVehicle, 1, k_NumberOfVehicleTypes);
                }
                catch (FormatException)
                {
                    Console.WriteLine("Invalid input! bad format");
                }
            }

            typeOfVehicleToAdd = (CreateVwhicleInGarage.eVehicleTypes)intUserChoiceForVehicle;

            switch (typeOfVehicleToAdd)
            {
            case CreateVwhicleInGarage.eVehicleTypes.Motorcycle:
                engineForVehicle = getEngineForUser(CreateVwhicleInGarage.eVehicleTypes.Motorcycle);
                wheelsForVehicle = getWheelsFromUser(Vehicle.eNuberOfWheelsForVehicle.TwoWheels, Vehicle.eMaximumAirPressure.MotorcycleAirPressure);
                Motorcycle.eLicenseType licenseType = getLicenseTypeFromUser();
                int engineVolume = getEngineVolumeFromUser();
                vehicleToAdd = CreateVwhicleInGarage.CreateMotorcycle(licenseType, engineVolume, vehicleModelName, i_VehicleLicensePlate, Vehicle.eMaximumAirPressure.MotorcycleAirPressure, wheelsForVehicle, engineForVehicle);
                break;

            case CreateVwhicleInGarage.eVehicleTypes.Car:
                engineForVehicle = getEngineForUser(CreateVwhicleInGarage.eVehicleTypes.Car);
                wheelsForVehicle = getWheelsFromUser(Vehicle.eNuberOfWheelsForVehicle.FourWheels, Vehicle.eMaximumAirPressure.CarAirPressure);
                Car.eNumbersOfDoors numberOfDoors = getNumberOfDoorsInCar();
                Car.eColor          carColor      = getCarColor();
                vehicleToAdd = CreateVwhicleInGarage.CreateCar(carColor, numberOfDoors, vehicleModelName, i_VehicleLicensePlate, Vehicle.eMaximumAirPressure.CarAirPressure, wheelsForVehicle, engineForVehicle);
                break;

            case CreateVwhicleInGarage.eVehicleTypes.Truck:
                engineForVehicle = getEngineForUser(CreateVwhicleInGarage.eVehicleTypes.Truck);
                wheelsForVehicle = getWheelsFromUser(Vehicle.eNuberOfWheelsForVehicle.TwelveWheels, Vehicle.eMaximumAirPressure.TruckAirPressure);
                bool  isTrunkCooled = askUserIfTruckTrunkCooled();
                float trunkVolume   = getTruckTrunkVolumeFromUser();
                vehicleToAdd = CreateVwhicleInGarage.CreateTruck(isTrunkCooled, trunkVolume, vehicleModelName, i_VehicleLicensePlate, Vehicle.eMaximumAirPressure.TruckAirPressure, wheelsForVehicle, engineForVehicle);
                break;
            }

            newVehicleToAddToTheGarage = CreateVwhicleInGarage.RegisterVehicleIntoGarage(vehicleOwnersName, vehicleOwnersPhoneNumber, vehicleToAdd);
            i_Garage.AddVehicleToTheGarageList(newVehicleToAddToTheGarage);
            Console.WriteLine("Vehicle added successfully");
        }
Пример #30
0
 public Car.eColor getCarColor()
 {
     Car.eColor carColor = (Car.eColor)getValidInt(CAR_COLOR, 1, 4);
     return(carColor);
 }