예제 #1
0
 public Car(string i_ModelName, string i_LicenseNumber, string i_OwnerName,
            string i_OwnerPhoneNumber, List <Wheel> i_wheels, eColor i_CarColor, eNumOfDoors i_NumOfDoors, EnergySystem i_energySystem)
     : base(i_ModelName, i_LicenseNumber, i_OwnerName, i_OwnerPhoneNumber, i_wheels, i_energySystem)
 {
     m_CarColor   = i_CarColor;
     m_NumOfDoors = i_NumOfDoors;
 }
예제 #2
0
        public Vehicle Construct(
            string i_ModelType,
            string i_LicensePlate,
            string i_WheelManufacturer,
            float[] i_TirePressures,
            eCarColor i_CarColor,
            eNumOfDoors i_NumOfDoors,
            float i_ChargeTimeLeft)
        {
            this.m_NumOfWheels       = k_NumOfWheels;
            this.m_ModelType         = i_ModelType;
            this.m_LicensePlate      = i_LicensePlate;
            this.m_WheelManufacturer = i_WheelManufacturer;
            for (int i = 0; i < k_NumOfWheels; i++)
            {
                this.m_Wheels[i] = new Wheel(m_WheelManufacturer, i_TirePressures[i], k_MaxTirePressure);
            }

            this.m_CarColor             = i_CarColor;
            this.m_NumOfDoors           = i_NumOfDoors;
            this.m_Engine               = new ElectricEngine(i_ChargeTimeLeft, k_MaxChargeTime);
            this.m_EnergyPrecentageLeft = i_ChargeTimeLeft / k_MaxChargeTime;

            return(this);
        }
예제 #3
0
        private eNumOfDoors getDoorsNumFromString(string i_ValStr)
        {
            eNumOfDoors doorsNum = new eNumOfDoors();

            Enum.TryParse(i_ValStr, out doorsNum);

            switch (doorsNum)
            {
            case (eNumOfDoors.Two):
                break;

            case (eNumOfDoors.Three):
                break;

            case (eNumOfDoors.Four):
                break;

            case (eNumOfDoors.Five):
                break;

            default:
                throw new ArgumentException("Number of doors is not optional!");
            }

            return(doorsNum);
        }
예제 #4
0
 public FuelCar(string i_ModelName, string i_LicenseNumber, float i_CurrentFuel, float i_MaxFuel, eFuelType i_FuelType, eNumOfDoors i_NumOfDoors, eColorType i_Color)
     : base(i_ModelName, i_LicenseNumber, i_CurrentFuel, i_MaxFuel, i_FuelType)
 {
     m_Color      = i_Color;
     m_NumOfDoors = i_NumOfDoors;
     UpdateEnergyPercentage();
 }
 /* Constructor */
 // Default constructor for the use of VehicleMaker class
 public ElectricBasedCar() : base()
 {
     this.m_Color      = eColorType.Unknown;
     this.m_NumOfDoors = eNumOfDoors.Unknown;
     MaxBatteryLife    = k_MaxBatteryLife;
     Type = eVehicleType.ElectricBasedCar;
     InitWheels();
 }
예제 #6
0
 public Car(eColors i_CarColor, eNumOfDoors i_NumOfDoors, HoldVehicleParams i_MyVehicle) : base(i_MyVehicle)
 {
     r_CarColor      = i_CarColor;
     r_CarNumOfDoors = i_NumOfDoors;
     if (i_MyVehicle.Wheels.Count > (int)eNumOfWheels.FourWheeledCar)
     {
         throw new ArgumentException(k_ErrNumOfWheels);
     }
 }
 /* Constructor */
 // Default constructor for the use of VehicleMaker class
 public FuelBasedCar() : base()
 {
     this.m_Color      = eColorType.Unknown;
     this.m_NumOfDoors = eNumOfDoors.Unknown;
     MaxAmountOfFuel   = k_MaxAmountOfFuel;
     Type     = eVehicleType.FuelBasedCar;
     FuelType = k_FuelType;
     InitWheels();
 }
예제 #8
0
        public override void InitializeVehicleWithAdditionalProps(string i_PathOfFileWithValuesToClassMembers)
        {
            string[] valsForMembers = File.ReadAllLines(i_PathOfFileWithValuesToClassMembers);

            //[0] is color:
            m_Color = getColorFromString(valsForMembers[0]);
            //[1] is num of doors:
            m_NumOfDoors = getDoorsNumFromString(valsForMembers[1]);
        }
예제 #9
0
 public Car(string i_Model, string i_LicenseNumber, string i_WheelManufacturerName, float i_WheelMaxAirPressure, eColor i_Color, eNumOfDoors i_NumberOfDoors, EnergySource i_DrivingForce)
     : base(i_Model, i_LicenseNumber)
 {
     this.r_Color                      = i_Color;
     this.r_NumberOfDoors              = i_NumberOfDoors;
     this.m_EnergySource               = i_DrivingForce;
     this.m_NumberOfWheels             = sr_CarNumberOfWheels;
     this.m_VehicleWheelMaxAirPressure = sr_CarWheelMaxAirPressure;
     this.AddWheels(i_WheelManufacturerName, i_WheelMaxAirPressure);
 }
예제 #10
0
 // $G$ DSN-011 (-5) No use internal constructors.
 public ElectricCar(string i_ModelName, string i_LicenseNumber, string i_WheelManufacturerName,
                    float i_CurrentWheelPressure, eCarColor i_CarColor, eNumOfDoors i_NumOfDoors) :
     base(i_ModelName, i_LicenseNumber, k_NumOfWheels, k_MaxBatteryTime)
 {
     r_CarColor   = i_CarColor;
     r_NumOfDoors = i_NumOfDoors;
     for (int i = 0; i < k_NumOfWheels; i++)
     {
         m_Wheels.Add(new Wheel(i_WheelManufacturerName, i_CurrentWheelPressure, k_MaxWheelAirPressure));
     }
 }
예제 #11
0
 public Car(string i_ModelName,
            string i_LicenseNumber,
            List <Wheel> i_Wheels,
            EnergySource i_EnergySource,
            eCarColor i_Color,
            eNumOfDoors i_Doors)
     : base(i_ModelName, i_LicenseNumber, i_Wheels, i_EnergySource)
 {
     Color = i_Color;
     Doors = i_Doors;
 }
예제 #12
0
 public FuelCar(string i_ModelName, string i_LicenseNumber, string i_WheelManufacturerName,
                float i_CurrentWheelPressure, eCarColor i_CarColor, eNumOfDoors i_NumOfDoors) :
     base(i_ModelName, i_LicenseNumber, k_NumOfWheels, eEnergyType.Octan98, k_MaxFuelLevel)
 {
     r_CarColor   = i_CarColor;
     r_NumOfDoors = i_NumOfDoors;
     for (int i = 0; i < k_NumOfWheels; i++)
     {
         m_Wheels.Add(new Wheel(i_WheelManufacturerName, i_CurrentWheelPressure, k_MaxWheelAirPressure));
     }
 }
예제 #13
0
        private static List <object> setListOfDetailsForCar(List <object> io_ListOfDetailsForVehicle)
        {
            Console.WriteLine("Please Enter the Car's Color: ");
            eCarColor carColor = verifyValidCarColor();

            io_ListOfDetailsForVehicle.Add(carColor);
            Console.WriteLine("Please Enter Number of Doors: ");
            eNumOfDoors numOfDoors = verifyNumberOfDoors();

            io_ListOfDetailsForVehicle.Add(numOfDoors);

            return(io_ListOfDetailsForVehicle);
        }
예제 #14
0
        private static eNumOfDoors verifyNumberOfDoors()
        {
            const int k_LowestPossibleInput = 1;
            int       highestPossibleInput  = Enum.GetNames(typeof(eNumOfDoors)).Length;

            Console.WriteLine(
                string.Format(
                    @"Choose number of doors (1-4):
1. Two
2. Three
3. Four
4. Five"));
            int         userInput  = manageUserInput(k_LowestPossibleInput, highestPossibleInput);
            eNumOfDoors eUserInput = (eNumOfDoors)userInput;

            return(eUserInput);
        }
예제 #15
0
        private bool setNumOfDoors(string i_NumOfDoors)
        {
            eNumOfDoors numOfDoors;
            bool        isValidinput = false;

            if (!Enum.TryParse(i_NumOfDoors, out numOfDoors))
            {
                throw new FormatException(string.Format("{0} is not parsable to number of doors", numOfDoors));
            }

            isValidinput = Enum.IsDefined(typeof(eNumOfDoors), numOfDoors);
            if (isValidinput)
            {
                m_NumOfDoors = numOfDoors;
            }

            return(isValidinput);
        }
        public ComposedVehicle CreateAutomobile(
            eValidVehicle i_eValidVehicle,
            string i_OwnerName,
            string i_OwnerPhoneNumber,
            string i_LicenseNumber,
            string i_ModelName,
            string i_WheelManufacturer,
            float i_WheelPressure,
            float i_CurrentPower,
            eColor i_eColor,
            eNumOfDoors i_eNumOfDoors)
        {
            Vehicle         vehicle;
            ComposedVehicle composedVehicle;

            if (i_eValidVehicle == eValidVehicle.RegCar)
            {
                vehicle = VehicleFactory.CreateAutomobile(
                    i_ModelName,
                    i_LicenseNumber,
                    i_WheelManufacturer,
                    i_WheelPressure,
                    i_CurrentPower,
                    i_eColor,
                    i_eNumOfDoors);
            }
            else
            {
                vehicle = VehicleFactory.CreateElectricAutomobile(
                    i_ModelName,
                    i_LicenseNumber,
                    i_WheelManufacturer,
                    i_WheelPressure,
                    i_CurrentPower,
                    i_eColor,
                    i_eNumOfDoors);
            }

            composedVehicle = new ComposedVehicle(vehicle, i_OwnerName, i_OwnerPhoneNumber);

            return(composedVehicle);
        }
예제 #17
0
        public override void SetVehiclePropertiesValues(int i_PropertyType, string i_PropertyValue)
        {
            int  valueInputFromUser;
            bool IsValidValue = int.TryParse(i_PropertyValue, out valueInputFromUser);

            if (IsValidValue)
            {
                eProperties propertyChoice = (eProperties)i_PropertyType;
                switch (propertyChoice)
                {
                case eProperties.eNumOfDoors:
                {
                    if (Enum.IsDefined(typeof(eNumOfDoors), valueInputFromUser))
                    {
                        m_numOfDoors = (eNumOfDoors)valueInputFromUser;
                        break;
                    }
                    else
                    {
                        throw new ValueOutOfRangeException(1, Enum.GetValues(typeof(eNumOfDoors)).Length, "Number of doors value is out of range");
                    }
                }

                case eProperties.eCarColor:
                {
                    if (Enum.IsDefined(typeof(eCarColor), valueInputFromUser))
                    {
                        m_CarColor = (eCarColor)valueInputFromUser;
                        break;
                    }
                    else
                    {
                        throw new ValueOutOfRangeException(1, Enum.GetValues(typeof(eCarColor)).Length, "Car color value is out of range");
                    }
                }
                }
            }
            else
            {
                throw new FormatException("Not a valid input");
            }
        }
예제 #18
0
        public static Vehicle CreateElectricAutomobile(
            string i_ModelName,
            string i_LicenseNumber,
            string i_WheelManufacturer,
            float i_CurrentAirPressure,
            float i_CurrentPower,
            eColor i_eColor,
            eNumOfDoors i_eNumOfDoors)
        {
            Vehicle electricAutomobile = new Automobile(
                i_ModelName,
                i_LicenseNumber,
                new Wheel(i_WheelManufacturer, 30, i_CurrentAirPressure),
                4,
                eVehicleStatus.OnRepair,
                new ElectricalSource(4.8f, i_CurrentPower),
                i_eColor,
                i_eNumOfDoors);

            return(electricAutomobile);
        }
예제 #19
0
        public ElectricCar(
            string i_ModelType,
            string i_LicensePlate,
            eCarColor i_CarColor,
            eNumOfDoors i_NumOfDoors,
            string i_WheelManufacturer,
            float[] i_TirePressures,
            float i_ChargeTimeLeft)
        {
            this.m_ModelType    = i_ModelType;
            this.m_LicensePlate = i_LicensePlate;
            foreach (float currentTirePressure in i_TirePressures)
            {
                this.m_Wheels.Add(new Wheel(i_WheelManufacturer, currentTirePressure, k_MaxTirePressure));
            }

            this.m_CarColor             = i_CarColor;
            this.m_NumOfDoors           = i_NumOfDoors;
            this.m_Engine               = new ElectricEngine(i_ChargeTimeLeft, k_MaxChargeTime);
            this.m_EnergyPrecentageLeft = i_ChargeTimeLeft / k_MaxChargeTime;
        }
예제 #20
0
        public static Vehicle CreateAutomobile(
            string i_ModelName,
            string i_LicenseNumber,
            string i_WheelManufacturer,
            float i_CurrentAirPressure,
            float i_CurrentPower,
            eColor i_eColor,
            eNumOfDoors i_eNumOfDoors)
        {
            Vehicle fueledAutomobile = new Automobile(
                i_ModelName,
                i_LicenseNumber,
                new Wheel(i_WheelManufacturer, 30, i_CurrentAirPressure),
                4,
                eVehicleStatus.OnRepair,
                new FuelSource(48, i_CurrentPower, eFuelType.Octan96),
                i_eColor,
                i_eNumOfDoors);

            return(fueledAutomobile);
        }
예제 #21
0
        public void UpdateNumOfDoors(string i_NumOfDoors)
        {
            if (int.TryParse(i_NumOfDoors, out int res))
            {
                var first = Enum.GetValues(typeof(eNumOfDoors)).Cast <eNumOfDoors>().First();
                var last  = Enum.GetValues(typeof(eNumOfDoors)).Cast <eNumOfDoors>().Last();

                if (res >= (int)first && res <= (int)last)
                {
                    Enum.TryParse <eNumOfDoors>(res.ToString(), out eNumOfDoors number);
                    m_NumOfDoors = number;
                }
                else
                {
                    throw new ValueOutOfRangeException(i_NumOfDoors, (int)first, (int)last);
                }
            }
            else
            {
                throw new FormatException("Invalid Numbe of doors");
            }
        }
예제 #22
0
        public override void SetMyValues(string i_CarColor, string i_NumOfDoors)
        {
            int numOfDoors;

            if (Enum.IsDefined(typeof(eCarColor), i_CarColor))
            {
                m_Color = (eCarColor)Enum.Parse(typeof(eCarColor), i_CarColor);
            }
            else
            {
                throw new FormatException("Invalid color choise");
            }

            if (int.TryParse(i_NumOfDoors, out numOfDoors) && numOfDoors >= k_MinNumOfDoors && numOfDoors <= k_MaxNumOfDoors)
            {
                m_NumOfDoors = (eNumOfDoors)numOfDoors;
            }
            else
            {
                throw new FormatException("Invalid num of doors choise");
            }
        }
예제 #23
0
        public FueledCar(
            string i_ModelType,
            string i_LicensePlate,
            string i_WheelManufacturer,
            float[] i_TirePressures,
            FueledEngine.eFuelType i_FuelType,
            float i_CurrentFuelAmount,
            eCarColor i_CarColor,
            eNumOfDoors i_NumOfDoors)
        {
            this.m_ModelType    = i_ModelType;
            this.m_LicensePlate = i_LicensePlate;
            foreach (float currentTirePressure in i_TirePressures)
            {
                this.m_Wheels.Add(new Wheel(i_WheelManufacturer, currentTirePressure, k_MaxTirePressure));
            }

            this.m_Engine = new FueledEngine(i_CurrentFuelAmount, k_MaxFueledEngine, FueledEngine.eFuelType.Octan98);
            this.m_EnergyPrecentageLeft = i_CurrentFuelAmount / k_MaxFueledEngine;
            this.m_CarColor             = i_CarColor;
            this.m_NumOfDoors           = i_NumOfDoors;
        }
예제 #24
0
파일: Car.cs 프로젝트: nis94/Garage
        public override void AddInfo(List <string> i_ExtraInfo)
        {
            base.AddInfo(i_ExtraInfo);

            if (int.Parse(i_ExtraInfo[4]) <= 4 && int.Parse(i_ExtraInfo[4]) >= 1)
            {
                m_Color = (eColor)int.Parse(i_ExtraInfo[4]);
            }
            else
            {
                throw new ArgumentException("No such color option!, Please enter details again");
            }

            if (int.Parse(i_ExtraInfo[5]) <= 5 && int.Parse(i_ExtraInfo[5]) >= 2)
            {
                m_NumOfDoors = (eNumOfDoors)int.Parse(i_ExtraInfo[5]);
            }
            else
            {
                throw new ArgumentException("No such number of doors!, Please enter details again");
            }
        }
예제 #25
0
        public Vehicle Construct(
            string i_ModelType,
            string i_LicensePlate,
            string i_WheelManufacturer,
            float[] i_TirePressures,
            eCarColor i_CarColor,
            eNumOfDoors i_NumOfDoors,
            float i_CurrentFuelAmount)
        {
            this.m_ModelType         = i_ModelType;
            this.m_LicensePlate      = i_LicensePlate;
            this.m_WheelManufacturer = i_WheelManufacturer;
            for (int i = 0; i < k_NumOfWheels; i++)
            {
                this.m_Wheels[i] = new Wheel(m_WheelManufacturer, i_TirePressures[i], k_MaxTirePressure);
            }

            this.m_Engine = new FueledEngine(i_CurrentFuelAmount, k_MaxFueledEngine, k_FuelType);
            this.m_EnergyPrecentageLeft = i_CurrentFuelAmount / k_MaxFueledEngine;
            this.m_CarColor             = i_CarColor;
            this.m_NumOfDoors           = i_NumOfDoors;

            return(this);
        }
예제 #26
0
        public static ElectricCar CreateElectricCar(string i_VehicleModel, string i_LicencePlate, float i_BatteryLeft, eCarColors i_Color, eNumOfDoors i_NumOfDoors,
                                                    string i_WheelMaker, float i_WheelCurrentPressure, VehicleOwner i_Owner)
        {
            ElectricCar electricCar = new ElectricCar(i_VehicleModel, i_LicencePlate, i_BatteryLeft, k_CarMaxBattery, i_Color, k_CarNumOfWheels, i_NumOfDoors, i_Owner);

            GenerateWheels(electricCar, k_CarMaxWheelPressure, i_WheelMaker, i_WheelCurrentPressure);

            return(electricCar);
        }
예제 #27
0
        public static Car CreateCar(string i_VehicleModel, string i_LicencePlate, float i_FuelLeft, eCarColors i_Color, eNumOfDoors i_NumOfDoors,
                                    string i_WheelMaker, float i_WheelCurrentPressure, VehicleOwner i_Owner)
        {
            Car car = new Car(i_VehicleModel, i_LicencePlate, i_FuelLeft, k_CarMaxFuel, k_CarNumOfWheels, i_Color, i_NumOfDoors, i_Owner);

            GenerateWheels(car, k_CarMaxWheelPressure, i_WheelMaker, i_WheelCurrentPressure);

            return(car);
        }
예제 #28
0
파일: Car.cs 프로젝트: nissimuseri/Garage
 public override void ChangeSpecificDetails(object i_ColorOfCar, object i_NumOfDoors)
 {
     m_ColorOfCar = (eColorOfCar)i_ColorOfCar;
     m_NumOfDoors = (eNumOfDoors)i_NumOfDoors;
 }
예제 #29
0
        /*** Class Logic ***/

        public void SetCarDoorsAndColor(Car.eColor i_Color, Car.eNumOfDoors i_NumOfDoors)
        {
            m_Color         = i_Color;
            m_NumberOfDoors = i_NumOfDoors;
        }
예제 #30
0
        public void SetFieldValue(Vehicle i_Vehicle, string i_FieldKey, string i_FieldValue)
        {
            switch (i_FieldKey)
            {
            case "Owner Name":
                i_Vehicle.Owner.Name = i_FieldValue;
                break;

            case "Owner Phone Number":
                i_Vehicle.Owner.PhoneNumber = i_FieldValue;
                break;

            case "Wheels Manufacturer":
                i_Vehicle.SetWheelsManufacturer(i_FieldValue);
                break;

            case "Wheels Pressure":
                float wheelsPressure = Validation.ValidateAndParseFloat(i_FieldValue);
                i_Vehicle.SetWheelsPressure(wheelsPressure);
                break;

            case "Current Fuel Amount (liters)":
                float currentFuelAmount = Validation.ValidateAndParseFloat(i_FieldValue);
                (i_Vehicle.Engine as FuelEngine).CurrentFuelAmount = currentFuelAmount;
                break;

            case "Time left in Battery (hours)":
                float currentTimeInBattery = Validation.ValidateAndParseFloat(i_FieldValue);
                (i_Vehicle.Engine as ElectricEngine).RemainingTimeInHours = currentTimeInBattery;
                break;

            case "Color":
                eColor color = Validation.ValidateAndParseEnum <eColor>(i_FieldValue);
                (i_Vehicle as Car).Color = color;
                break;

            case "Number Of Doors":
                eNumOfDoors numOfDoors = Validation.ValidateAndParseEnum <eNumOfDoors>(i_FieldValue);
                (i_Vehicle as Car).NumOfDoors = numOfDoors;
                break;

            case "License Type":
                eLicenseType licenseType = Validation.ValidateAndParseEnum <eLicenseType>(i_FieldValue);
                (i_Vehicle as Motorcycle).LicenseType = licenseType;
                break;

            case "Engine Volume":
                int engineVolume = Validation.ValidateAndParseInt(i_FieldValue);
                (i_Vehicle as Motorcycle).EngineVolume = engineVolume;
                break;

            case "if it Contains Dangerous Materials":
                bool containsDangerousMaterials = Validation.ValidateAndParseBool(i_FieldValue);
                (i_Vehicle as Truck).ContainsDangerousMaterials = containsDangerousMaterials;
                break;

            case "Volume of Cargo":
                float volumeOfCargo = Validation.ValidateAndParseFloat(i_FieldValue);
                (i_Vehicle as Truck).VolumeOfCargo = volumeOfCargo;
                break;
            }
        }