Ejemplo n.º 1
0
        private static eCarColor verifyValidCarColor()
        {
            int lowestPossibleInput  = 1;
            int highestPossibleInput = Enum.GetNames(typeof(eCarColor)).Length;

            Console.WriteLine(
                string.Format(
                    @"Choose Relevant Car Color (1-4):
1. Yellow
2. Black
3. White
4. Blue"));
            int       userInput  = manageUserInput(lowestPossibleInput, highestPossibleInput);
            eCarColor eUserInput = (eCarColor)userInput;

            return(eUserInput);
        }
Ejemplo n.º 2
0
        internal Car(string i_ModelName, string i_LicenseNumber, float i_CurrentEnergy, float i_MaxEnergyCapacity, eEnergyType i_EnergyType, LinkedList <Wheel> i_Wheels,
                     eVehicleType i_VehicleType, eCarColor i_CarColor, int i_DoorsAmount) : base(i_ModelName, i_LicenseNumber, i_CurrentEnergy, i_MaxEnergyCapacity, i_EnergyType, i_Wheels, i_VehicleType)
        {
            if (i_DoorsAmount < 2 || i_DoorsAmount > 5)
            {
                throw new ValueOutOfRangeException(2, 5);
            }

            try
            {
                m_CarColor    = i_CarColor;
                m_DoorsAmount = i_DoorsAmount;
            }
            catch (FormatException exception)
            {
                throw exception;
            }
        }
Ejemplo n.º 3
0
        public Car(
            string i_ModelName,
            string i_LicensePlate,
            float i_EnergyPercentage,
            Wheel[] i_Wheels,
            EnergySource i_EnergySource,
            eCarColor i_Color,
            int i_NumOfDoors)
            : base(i_ModelName, i_LicensePlate, i_EnergyPercentage, i_Wheels, i_EnergySource)
        {
            if (i_NumOfDoors > r_MaxNumOfDoors || i_NumOfDoors < r_MinNumOfDoors)
            {
                throw new ValueOutOfRangeException(r_MaxNumOfDoors, r_MinNumOfDoors, "Number of doors");
            }

            m_Color      = i_Color;
            m_NumOfDoors = i_NumOfDoors;
        }
        public void TheChoiseOfUserIsAutomobile()
        {
            String ColorOfCar = String.Format(@"Please, type your color : 
1: Green
2: Black
3: Red
4: Silver");

            Console.WriteLine(ColorOfCar);
            eCarColor colorOfCar = (eCarColor)(Convert.ToInt32(Console.ReadLine()));

            Console.Clear();

            String CountOfDoors = String.Format(@"Please, type your countOfDoors : 
2: TwoDoors
3: TreeDoors
4: FourDoors
5: FiveDoors");

            Console.WriteLine(ColorOfCar);
            eCountOfDoors countOfDoors = (eCountOfDoors)(Convert.ToInt32(Console.ReadLine()));

            Console.Clear();

            Console.WriteLine("Please type your current fuel ");
            float currentAmountFuel = Convert.ToInt32(Console.ReadLine());

            Console.Clear();


            if (m_MyGarage.VehicleCollection.ContainsKey(m_LicenseNumber))
            {
                Console.WriteLine("Auto exist in Garraje && in repairing !!!!");
                m_MyGarage.VehicleCollection[m_LicenseNumber].EVecihleStates = eVecihleState.Repairing;
            }
            else
            {
                OwnerData AutomobileOwner = new OwnerData(m_ClientName, m_TelefonNumber,
                                                          new Automobile(m_WheelManufacturer, m_CurrentPressure, m_ModelCar, m_LicenseNumber,
                                                                         currentAmountFuel, colorOfCar, countOfDoors));

                m_MyGarage.AddVehicleToGarrage(m_LicenseNumber, AutomobileOwner);
            }
        }
Ejemplo n.º 5
0
        private void putNewCarInGarage(string i_LicenseNumber, string i_ModelName, float i_PercentageOfEnergyLeft, VehicleInGarage i_VehicleInGarage, List <Wheel> i_Wheels)
        {
            eCarColor      carColor      = inputCarColor();
            eNumberOfDoors numberOfDoors = inputNumberOfDoors();

            Console.WriteLine(string.Format(@"choose the type of vehicle you want:
for fuel engine car - press 1
for electric engine car - press any other key"));
            string choice = Console.ReadLine();

            if (choice == "1")
            {
                putNewFuelCarInGarage(i_LicenseNumber, i_ModelName, i_PercentageOfEnergyLeft, carColor, numberOfDoors, i_VehicleInGarage, i_Wheels);
            }
            else
            {
                putNewElectricCarInGarage(i_LicenseNumber, i_ModelName, i_PercentageOfEnergyLeft, carColor, numberOfDoors, i_VehicleInGarage, i_Wheels);
            }
        }
        public void TheChoiceOfUserIsElectricAutomobile()
        {
            float  currentEnergyCharge = 0;
            String ColorOfCar          = String.Format(@"Please, type your color : 
1: Green
2: Black
3: Red
4: Silver");

            Console.WriteLine(ColorOfCar);
            eCarColor colorOfCar = (eCarColor)(Convert.ToInt32(Console.ReadLine()));

            Console.Clear();

            String CountOfDoors = String.Format(@"Please, type your countOfDoors : 
2: TwoDoors
3: TreeDoors
4: FourDoors
5: FiveDoors");

            Console.WriteLine(ColorOfCar);
            eCountOfDoors countOfDoors = (eCountOfDoors)(Convert.ToInt32(Console.ReadLine()));

            Console.Clear();

            Console.WriteLine("Please type your current energy status in Hours , for example if you get 1/2 of hours type 0.5");
            float.TryParse(Console.ReadLine(), out currentEnergyCharge);
            Console.Clear();

            if (m_MyGarage.VehicleCollection.ContainsKey(m_LicenseNumber))
            {
                Console.WriteLine("Auto exist in Garraje && in repairing !!!!");
                m_MyGarage.VehicleCollection[m_LicenseNumber].EVecihleStates = eVecihleState.Repairing;
            }
            else
            {
                OwnerData ElectricAutomobileOwner = new OwnerData(m_ClientName, m_TelefonNumber,
                                                                  new ElectricAutomobile(m_WheelManufacturer, m_CurrentPressure, m_ModelCar, m_LicenseNumber,
                                                                                         currentEnergyCharge, colorOfCar, countOfDoors));
                m_MyGarage.AddVehicleToGarrage(m_LicenseNumber, ElectricAutomobileOwner);
            }
        }
Ejemplo n.º 7
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");
            }
        }
Ejemplo n.º 8
0
        internal Car(string io_ModelName,
                     string io_LicenseNumber, List <Wheel> io_Wheels,
                     Engine.eEngineType io_EngineType, float io_EenergyLeft,
                     List <object> io_UniqueParametersList) : base(io_ModelName, io_LicenseNumber, io_Wheels, io_EngineType, io_EenergyLeft, eVehicleType.Car)
        {
            try
            {
                m_CarColor    = (eCarColor)io_UniqueParametersList[0];
                m_DoorsAmount = int.Parse((string)io_UniqueParametersList[1]);

                if (m_DoorsAmount < 2 || m_DoorsAmount > 5)
                {
                    throw new ValueOutOfRangeException(2, 5);
                }
            }
            catch (FormatException exception)
            {
                throw exception;
            }
        }
Ejemplo n.º 9
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;
        }
Ejemplo n.º 10
0
        public void UpdateNewCarInput(int i_CarColor, int i_AmountOfDoors)
        {
            switch (i_AmountOfDoors)
            {
            case 2:
                m_AmountOfDoors = eCarDoors.TWO;
                break;

            case 3:
                m_AmountOfDoors = eCarDoors.THREE;
                break;

            case 4:
                m_AmountOfDoors = eCarDoors.FOUR;
                break;

            case 5:
                m_AmountOfDoors = eCarDoors.FIVE;
                break;
            }

            switch (i_CarColor)
            {
            case 1:
                m_CarColor = eCarColor.Red;
                break;

            case 2:
                m_CarColor = eCarColor.Blue;
                break;

            case 3:
                m_CarColor = eCarColor.Grey;
                break;

            case 4:
                m_CarColor = eCarColor.Black;
                break;
            }
        }
Ejemplo n.º 11
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");
            }
        }
Ejemplo n.º 12
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;
        }
Ejemplo n.º 13
0
        internal bool ValidInputCarColor(string i_InputString, ref eCarColor eCarColor)
        {
            bool isValid = false;

            try
            {
                if (i_InputString == "Grey" || i_InputString == "1")
                {
                    eCarColor = GarageLogic.eCarColor.Grey;
                    isValid   = true;
                }
                else if (i_InputString == "Blue" || i_InputString == "2")
                {
                    eCarColor = GarageLogic.eCarColor.Blue;
                    isValid   = true;
                }
                else if (i_InputString == "White" || i_InputString == "3")
                {
                    eCarColor = GarageLogic.eCarColor.White;
                    isValid   = true;
                }
                else if (i_InputString == "Black" || i_InputString == "4")
                {
                    eCarColor = GarageLogic.eCarColor.Black;
                    isValid   = true;
                }
                else
                {
                    throw new ArgumentException();
                }
            }
            catch (ArgumentException)
            {
                Console.WriteLine("{0} is Not an Options. Please Try Again: [Grey(1) /Blue(2) /White(3) /Black(4)]", i_InputString);
            }

            return(isValid);
        }
Ejemplo n.º 14
0
        public override void UpdateSpecificPropeties(string i_CarColorFromUser, string i_NumberOfDoorsFromUser)
        {
            bool isParseAble = false;

            m_CarColor = (eCarColor)Enum.Parse(typeof(eCarColor), i_CarColorFromUser);
            if ((int)m_CarColor > (int)Enum.GetValues(typeof(eCarColor)).Cast <eCarColor>().Last() || (int)m_CarColor < 0)
            {
                throw new ValueOutOfRangeException(4, 1, "CarColor");
            }

            isParseAble = int.TryParse(i_NumberOfDoorsFromUser, out m_NumberOfDoors);
            if (isParseAble)
            {
                if (m_NumberOfDoors < 2 || m_NumberOfDoors > 5)
                {
                    throw new ValueOutOfRangeException(5, 2, "Number Of Doors");
                }
            }
            else
            {
                throw new FormatException();
            }
        }
Ejemplo n.º 15
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);
        }
Ejemplo n.º 16
0
        public override void FulfillVehicleDetails(VehicleEntranceForm i_VehicleEntranceForm)
        {
            Model         = i_VehicleEntranceForm.VehicleModel;
            m_Color       = i_VehicleEntranceForm.CarColor;
            m_DoorsNumber = i_VehicleEntranceForm.CarDoorsNumber;

            if (i_VehicleEntranceForm.VehicleType == VehicleFactory.eVehicleType.ElectricMotorcycle)
            {
                Engine = new ElectricEngine(i_VehicleEntranceForm.RemainingBatteryHours, k_MaximumBatteryLifeHours);
            }
            else
            {
                Engine = new GasolineEngine(k_CarFuelType, i_VehicleEntranceForm.CurrentFuelAmount, k_CarVolumeOfFuelTank);
            }

            for (int i = 0; i < k_NumberOfWheelsInCar; i++)
            {
                Wheel WheelToAdd = new Wheel(
                    i_VehicleEntranceForm.WheelManufacturer,
                    i_VehicleEntranceForm.WheelCurrentAirPressure,
                    k_MaximumAirPressure);
                Wheels.Add(WheelToAdd);
            }
        }
Ejemplo n.º 17
0
 public override void FillRestDetails(object i_DatailsOne, object i_DetailsTwo)
 {
     this.DoorsAmount = (eDoorsAmount)i_DatailsOne;
     this.Color       = (eCarColor)i_DetailsTwo;
 }
Ejemplo n.º 18
0
 public ElectricCar(string i_ModelName, string i_LicenseNumber, float i_BatteryTimeLeftByHours, eCarColor i_Color, eDoorsNumber i_DoorNumber, Wheel[] i_Wheels)
     : base(i_ModelName, i_LicenseNumber, i_BatteryTimeLeftByHours, k_MaxBatteryTime, k_NumberOfWheels, i_Wheels, k_MaxWheelAirPressure)
 {
     m_CarProperties = new CarProperties(i_Color, i_DoorNumber);
 }
Ejemplo n.º 19
0
        public ElectricCar CreateNewElectricCar(ElectricEngine i_ElectriclEngine, eNumberOfDoors i_NumberOfDoors, eCarColor i_CarColor, string i_ModelName, string i_LicenseNumber, float i_ThePercentageOfEnergyLeft, List <Wheel> i_Wheels)
        {
            ElectricCar electricCar = new ElectricCar(i_ElectriclEngine, i_NumberOfDoors, i_CarColor, i_ModelName, i_LicenseNumber, i_ThePercentageOfEnergyLeft, i_Wheels);

            return(electricCar);
        }
Ejemplo n.º 20
0
        public FuelCar CreateNewFuelCar(FuelEngine i_FuelVehicle, eNumberOfDoors i_NumberOfDoors, eCarColor i_CarColor, string i_ModelName, string i_LicenseNumber, float i_ThePercentageOfEnergyLeft, List <Wheel> i_Wheels)
        {
            FuelCar fuelCar = new FuelCar(i_FuelVehicle, i_NumberOfDoors, i_CarColor, i_ModelName, i_LicenseNumber, i_ThePercentageOfEnergyLeft, i_Wheels);

            return(fuelCar);
        }
Ejemplo n.º 21
0
 public Car(string i_ModelName, string i_LicenseNumber, List <Wheel> i_Wheel, Motor i_Motor, eCarColor i_CarColor, eNumOfCarDoors i_NumOfCarDoors) : base(i_ModelName, i_LicenseNumber, i_Wheel, i_Motor)
 {
     m_CarColor      = i_CarColor;
     r_NumOfCarDoors = i_NumOfCarDoors;
 }
Ejemplo n.º 22
0
 public Car(string i_LicenseNumber, Collection <Tire> i_TiresCollection, Engine i_VehicleEngine, eCarColor i_CarColor, eNumberOfDoors i_NumberOfDoors)
     : base(i_LicenseNumber, i_TiresCollection, i_VehicleEngine)
 {
     r_CarColor      = i_CarColor;
     r_NumberOfDoors = i_NumberOfDoors;
 }
Ejemplo n.º 23
0
 public ElectricCar(string i_ModelName, string i_LicenceID, eCarColor ColorOfCar, eDoorsAmount AmountOfDoors, string i_WheelsManfacturer, float i_AmountOfCurrentBattryLeft) :
     base(i_ModelName, i_LicenceID, ColorOfCar, AmountOfDoors, i_WheelsManfacturer)
 {
     asssaignEnergySourceToElectric(ref EnergySourceByRef, i_AmountOfCurrentBattryLeft, k_MaxBatteryTime, EnergyType.Electric);
 }
Ejemplo n.º 24
0
        public override void SetListOfMembersToIntialize(int i_MemberIndexInEnum, string i_MemberValue)
        {
            eCarMembersToInitialize vehicleMember = (eCarMembersToInitialize)i_MemberIndexInEnum;
            int memberValue;

            switch (vehicleMember)
            {
            case eCarMembersToInitialize.Model:
            {
                m_ModelName = i_MemberValue;
                break;
            }

            case eCarMembersToInitialize.CarColor:
            {
                if (checkIfEnumContainThisChoice <eCarColor>(i_MemberValue, out memberValue))
                {
                    m_CarColor = (eCarColor)memberValue;
                }
                else
                {
                    if (int.TryParse(i_MemberValue, out memberValue))
                    {
                        if (Enum.IsDefined(typeof(eCarColor), memberValue))
                        {
                            m_CarColor = (eCarColor)memberValue;
                        }
                        else
                        {
                            throw new ArgumentException("There isn't such color.");
                        }
                    }
                    else
                    {
                        throw new FormatException("The value is invalid.");
                    }
                }

                break;
            }

            case eCarMembersToInitialize.NumberOfDoors:
            {
                if (checkIfEnumContainThisChoice <eNumberOfDoors>(i_MemberValue, out memberValue))
                {
                    m_NumberOfDoors = (eNumberOfDoors)memberValue;
                }
                else
                {
                    if (int.TryParse(i_MemberValue, out memberValue))
                    {
                        if (Enum.IsDefined(typeof(eNumberOfDoors), memberValue))
                        {
                            m_NumberOfDoors = (eNumberOfDoors)memberValue;
                        }
                        else
                        {
                            throw new ArgumentException("There isn't such option of doors.");
                        }
                    }
                    else
                    {
                        throw new FormatException("The value is invalid.");
                    }
                }

                break;
            }
            }
        }
Ejemplo n.º 25
0
 internal FuelCar(FuelEngine i_FuelVehicle, eNumberOfDoors i_NumberOfDoors, eCarColor i_CarColor, string i_ModelName, string i_LicenseNumber, float i_ThePercentageOfEnergyLeft, List <Wheel> i_Wheels) : base(i_NumberOfDoors, i_CarColor, i_ModelName, i_LicenseNumber, i_ThePercentageOfEnergyLeft, i_Wheels)
 {
     m_FuelEngine = i_FuelVehicle;
 }
Ejemplo n.º 26
0
 public override void FillDetails(SpecificDetailsForm i_DetailsForm)
 {
     m_CarColor      = i_DetailsForm.CarColor;
     m_NumberOfDoors = i_DetailsForm.NumberOfDoors;
     UpdateEnergyPercent();
 }
Ejemplo n.º 27
0
 public FuelCar(string i_ModelName, string i_LicenseNumber, float i_CurrentEnergy, float i_MaxEnergyCapacity, eEnergyType i_EnergyType, LinkedList <Wheel> i_Wheels,
                eCarColor i_CarColor, int i_DoorsAmount) : base(i_ModelName, i_LicenseNumber, i_CurrentEnergy, i_MaxEnergyCapacity, i_EnergyType, i_Wheels, eVehicleType.FueledCar, i_CarColor, i_DoorsAmount)
 {
 }
 public Automobile(string i_WheelProducer, float i_CurrentAirPressure, string i_ModelOfCar, string i_License, float i_FuelorElectricyAmount, eCarColor i_Color,
                   eCountOfDoors i_NumberOfDoors) : base(i_WheelProducer, i_CurrentAirPressure, i_ModelOfCar, i_License, i_FuelorElectricyAmount,
                                                         k_NumberOfWheels, m_FuelType, k_MaximalFuelCapacity, k_MaxWheelAirPressure)
 {
     m_CarColor    = i_Color;
     eCountOfdoors = i_NumberOfDoors;
 }
Ejemplo n.º 29
0
 public Car(List<object> i_InputParamsFromUser)
     : base(i_InputParamsFromUser, k_AmountOfTires, k_CarWheelsMaximalAirPressure)
 {
     this.r_CarColor = (eCarColor)i_InputParamsFromUser[4];
     this.r_AmountOfDoors = (eAmountOfDoors)i_InputParamsFromUser[5];
 }
Ejemplo n.º 30
0
 public FuelCar(string i_ModelName, string i_LicenseNumber, float i_CurrentFuelQuantity, eCarColor i_CarColor, eDoorsNumber i_DoorsNumber, Wheel[] i_Wheel)
     : base(i_ModelName, i_LicenseNumber, k_FuelType, i_CurrentFuelQuantity, k_MaxFuelQuantity, k_NumberOfWheels, i_Wheel, k_MaxWheelAirPressure)
 {
     m_CarProperties = new CarProperties(i_CarColor, i_DoorsNumber);
 }