Example #1
0
        private bool tryParseLicense(string i_Value, out eLicenseType o_Licene)
        {
            bool validLicene = false;
            if (Enum.TryParse(i_Value, out o_Licene))
            {
                if (Enum.IsDefined(typeof(eLicenseType), o_Licene))
                {
                    validLicene = true;
                }
            }

            return validLicene;
        }
Example #2
0
 public Motorcycle(eLicenseType i_LicenseType, Engine i_Engine, float i_EngineCC, string i_Model, string i_LicenseNumber, List <Wheel> i_Wheels) :
     base(i_Model, i_LicenseNumber, i_Engine, i_Wheels)
 {
     m_LicenseType = i_LicenseType;
     m_EngineCC    = i_EngineCC;
 }
Example #3
0
 public FuelBike(string i_ModelName, string i_LicenseNumber,
                 string i_WheelManufacturerName, float i_CurrentWheelPressure, eLicenseType i_LicenseType, int i_EngineCCVolume) :
     base(i_ModelName, i_LicenseNumber, k_NumOfWheels, eEnergyType.Octan95, k_MaxFuelLevel)
 {
     r_LicenseType    = i_LicenseType;
     r_EngineCcVolume = i_EngineCCVolume;
     for (int i = 0; i < k_NumOfWheels; i++)
     {
         m_Wheels.Add(new Wheel(i_WheelManufacturerName, i_CurrentWheelPressure, k_MaxWheelAirPressure));
     }
 }
Example #4
0
        public static Vehicle CreateNewVehicle(Garage i_Garage, eVehicleTypes vehicleType, Dictionary <string, string> i_Properties)
        {
            Vehicle      i_Vehicle;
            bool         creationSuccess = false;
            string       modelName = "", licensePlate = "", manufacture = "";
            float        engineCapacity = 0, loadVolume = 0;
            bool         isCarryingDangerousLoad = false;
            eCarDoors    door        = eCarDoors.Five;
            eColor       color       = eColor.Black;
            eLicenseType licenseType = eLicenseType.A;

            foreach (KeyValuePair <string, string> pairs in i_Properties)
            {
                switch (pairs.Key)
                {
                case "Model Name":
                    modelName = pairs.Value;
                    break;

                case "License Plate":
                    licensePlate = pairs.Value;
                    break;

                case "Manufacture":
                    manufacture = pairs.Value;
                    break;

                case "Car Color":
                    eColor.TryParse(pairs.Value, out color);
                    break;

                case "Number of Doors":
                    eCarDoors.TryParse(pairs.Value, out door);
                    break;

                case "Engine Capacity CCS":
                    engineCapacity = float.Parse(pairs.Value);
                    break;

                case "License Type":
                    eLicenseType.TryParse(pairs.Value, out licenseType);
                    break;

                case "Is carrying dangerous load":
                    isCarryingDangerousLoad = bool.Parse(pairs.Value);
                    break;

                case "Load Volume":
                    loadVolume = float.Parse(pairs.Value);
                    break;
                }
            }

            switch (vehicleType)
            {
            case eVehicleTypes.ElectronicCar:
                i_Vehicle = new ElectricCar(modelName, licensePlate, color, door, manufacture);
                //ElectricCar.TryParse(i_Properties, out newVehicle);
                break;

            case eVehicleTypes.ElectronicMotorCycle:
                i_Vehicle = new ElectricMotorCycle(modelName, licensePlate, engineCapacity, eLicenseType.A1, manufacture);
                break;

            case eVehicleTypes.FuelCar:
                i_Vehicle = new FuelCar(modelName, licensePlate, color, door, manufacture);
                //FuelCar.TryParse(i_Properties, out newVehicle);
                break;

            case eVehicleTypes.FuelMotorCycle:
                i_Vehicle = new FuelMotorCycle(modelName, licensePlate, engineCapacity, licenseType, manufacture);
                break;

            case eVehicleTypes.Truck:
                i_Vehicle = new Truck(modelName, licensePlate, manufacture, isCarryingDangerousLoad, loadVolume);
                break;

            default:
                i_Vehicle = null;
                break;
            }
            return(i_Vehicle);
        }
Example #5
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;
            }
        }
Example #6
0
 public FuelMotorCycle(string i_ModelName, string i_LicensePlate, float i_EngineCapacity, eLicenseType i_LicenseType, string i_Manufacture)
     : base(i_ModelName, i_LicensePlate, i_EngineCapacity, i_LicenseType, new FuelEnergy(k_FuelType, k_MaxAmountOfFuel), i_Manufacture)
 {
 }
 public MotorCycle(string i_Model, string i_LicenseNumber, string i_WheelManufacturerName, float i_WheelMaxAirPressure, eLicenseType i_LicenseType, int i_EngineCapacity, EnergySource i_EnergySource)
     : base(i_Model, i_LicenseNumber)
 {
     this.r_LicenseType                = i_LicenseType;
     this.r_EngineVolume               = i_EngineCapacity;
     this.m_EnergySource               = i_EnergySource;
     this.m_NumberOfWheels             = sr_MotorCycleNumberOfWheels;
     this.m_VehicleWheelMaxAirPressure = sr_MotorCycleWheelMaxAirPressure;
     this.AddWheels(i_WheelManufacturerName, i_WheelMaxAirPressure);
 }
Example #8
0
 public Motorcycle(string i_ModelName, string i_LicenseNumber, List <Wheel> i_Wheel, Motor i_Motor, eLicenseType i_LicenseType, int i_MotorCapacity) : base(i_ModelName, i_LicenseNumber, i_Wheel, i_Motor)
 {
     m_LicenseType   = i_LicenseType;
     m_MotorCapacity = i_MotorCapacity;
 }
Example #9
0
 internal Motorcycle(Motor i_Motor, Wheel[] i_Wheels, float i_MaxWheelPressure, string i_LicensePlateNumber, string i_Model, eLicenseType i_LicenseType, int i_EngineVolume)
     : base(i_Motor, i_Wheels, i_MaxWheelPressure, i_LicensePlateNumber, i_Model)
 {
     r_LicenseType  = i_LicenseType;
     r_EngineVolume = i_EngineVolume;
 }
 /**
  * This method overrides the base's method
  * Receives an array of answers and updates the fields accordingly
  */
 public override void UpdateUniqueFields(List <object> i_ListOfUniqueInfoAnswers)
 {
     m_LicenseType  = (eLicenseType)int.Parse((string)i_ListOfUniqueInfoAnswers[0]);
     m_EngineVolume = int.Parse((string)i_ListOfUniqueInfoAnswers[1]);
 }
 public override void SetUniqueFeatures(params object[] i_UniqueFeatures)
 {
     m_TypeOfLicense = (eLicenseType)i_UniqueFeatures[0];
     m_Cc            = (int)i_UniqueFeatures[1];
 }
Example #12
0
        private void putNewFuelEngineMotorcycle(string i_LicenseNumber, string i_ModelName, float i_PercentageOfEnergyLeft, eLicenseType i_LicenseType, int i_EngineCapacity, VehicleInGarage i_VehiclesInGarage, List <Wheel> i_Wheels)
        {
            eFuelType fuelType          = FuelMotorcycle.k_FuelType;
            float     maxFuelInLiter    = FuelMotorcycle.k_MaxFuelInLiter;
            float     currentFuelAmount = inputCurrentFuelAmount(maxFuelInLiter);

            FuelEngine     fuelEngine     = m_VehicleManufacturer.createNewFuelEngine(fuelType, currentFuelAmount, maxFuelInLiter);
            FuelMotorcycle fuelMotorcycle = m_VehicleManufacturer.CreateNewFuelMotorcycle(fuelEngine, i_LicenseType, i_EngineCapacity, i_ModelName, i_LicenseNumber, i_PercentageOfEnergyLeft, i_Wheels);

            i_VehiclesInGarage.CustomerVehicle = fuelMotorcycle;
            m_Garage.PutANewCarIntoTheGarage(i_VehiclesInGarage);
        }
Example #13
0
        private void putNewElectricEngineMotorcycle(string i_LicenseNumber, string i_ModelName, float i_PercentageOfEnergyLeft, eLicenseType i_LicenseType, int i_EngineCapacity, VehicleInGarage i_VehiclesInGarage, List <Wheel> i_Wheels)
        {
            float maxBbatteryTimeInHours = ElectricMotorcycle.k_MaxBbatteryTimeInHours;
            float batteryTimeInHoursLeft = inputBatteryTimeInHoursLeft(maxBbatteryTimeInHours);

            ElectricEngine     electricEngine     = m_VehicleManufacturer.createNewElectricEngine(batteryTimeInHoursLeft, maxBbatteryTimeInHours);
            ElectricMotorcycle electricMotorcycle = m_VehicleManufacturer.createNewElectricMotorcycle(electricEngine, i_LicenseType, i_EngineCapacity, i_ModelName, i_LicenseNumber, i_EngineCapacity, i_Wheels);

            i_VehiclesInGarage.CustomerVehicle = electricMotorcycle;
            m_Garage.PutANewCarIntoTheGarage(i_VehiclesInGarage);
        }
Example #14
0
 public Motor(eLicenseType i_LicenseType, int i_EngineVolume, string i_ModelName, string i_LicensingNumber, float i_LeftEnergy, Wheel[] i_Wheels, Engine i_Engine, string i_ManufacturerName, float i_CurrAirPressure, float i_MaxAirPressure)
     : base(i_ModelName, i_LicensingNumber, i_LeftEnergy, i_Wheels, i_Engine, i_ManufacturerName, i_CurrAirPressure, i_MaxAirPressure)
 {
     m_LicenseType  = i_LicenseType;
     m_EngineVolume = i_EngineVolume;
 }
Example #15
0
        private void getMotorcycleLicenseType()
        {
            bool isValidMenuInput = true;

            do
            {
                try
                {
                    m_LicenseTypeOfMotorcycle = (eLicenseType)parseEnumUserInput(
            @"Please enter the new motorcycle License Type by choosing a number from the menu:
            1. A
            2. A1
            3. AA
            4. B1",
            typeof(eLicenseType));

                    isValidMenuInput = Enum.IsDefined(typeof(eLicenseType), m_LicenseTypeOfMotorcycle);
                    if (!isValidMenuInput)
                    {
                        Console.WriteLine("Invalid license type input");
                    }
                }
                catch (ArgumentException ex)
                {
                    isValidMenuInput = false;
                    Console.WriteLine(ex.Message);
                }
                catch (Exception ex)
                {
                    isValidMenuInput = false;
                    Console.WriteLine(ex.Message);
                }
            }
            while (!isValidMenuInput);
        }
Example #16
0
 internal ElectricMotorcycle(ElectricEngine i_ElectriclVehicle, eLicenseType i_LicenseType, int i_EngineCapacity, string i_ModelName, string i_LicenseNumber, float i_ThePercentageOfEnergyLeft, List <Wheel> i_Wheels) : base(i_LicenseType, i_EngineCapacity, i_ModelName, i_LicenseNumber, i_ThePercentageOfEnergyLeft, i_Wheels)
 {
     m_ElectricEngine = i_ElectriclVehicle;
 }
Example #17
0
 public ElectricMotorcycel(eLicenseType i_LicenseType, float i_BatteryTimeremainingInhours, int i_EngineVolumeInCc, string i_ModelName, string i_LicenseNumber,
                           float i_PercentageOfEnergyRemainingInItsEnergysource, string i_WheelManufacturerName, float i_CurrentAirPressur) :
     base(i_LicenseType, i_EngineVolumeInCc, i_ModelName, i_LicenseNumber,
          i_PercentageOfEnergyRemainingInItsEnergysource, i_WheelManufacturerName, i_CurrentAirPressur, new ElectricalEnergy(k_MaximumBatteryInHours * 60, i_BatteryTimeremainingInhours * 60))
 {
 }
Example #18
0
 public Motorcycle(eLicenseType i_LicenseType, int i_EngineCapacity, EnergyStorage i_EnergyStorage, string i_ModelName, string i_LicenseNumber, List <Tire> i_Wheels, float i_EnergyPercentage)
     : base(i_ModelName, i_LicenseNumber, i_Wheels, i_EnergyStorage, i_EnergyPercentage)
 {
     r_LicenseType    = i_LicenseType;
     r_EngineCapacity = i_EngineCapacity;
 }
Example #19
0
 override public void SetSpecificDetails(params object[] i_Details)
 {
     m_EngineDisplacement = (int)i_Details[0];
     m_LicenseType        = (eLicenseType)i_Details[1];
 }
Example #20
0
 public override void SetInfo(List <string> i_VehicleInfo)
 {
     base.SetInfo(i_VehicleInfo);
     m_WheelsList  = Wheel.SetWheels(i_VehicleInfo[4], i_VehicleInfo[5], k_MaxPsi, k_NumberOfWheels);
     m_LicenseType = checkLicenseType(i_VehicleInfo[6]);
 }
 internal FuelMotorcycle(string i_ModelName, string i_LicenseNumber, float i_CurrentEnergy,
                         float i_MaxEnergyCapacity, eEnergyType i_EnergyType, LinkedList <Wheel> i_Wheels, eLicenseType i_LicenseType,
                         int i_MotorVolume) : base(i_ModelName, i_LicenseNumber, i_CurrentEnergy, i_MaxEnergyCapacity, i_EnergyType,
                                                   i_Wheels, eVehicleType.FueledMotorcycle, i_LicenseType, i_MotorVolume)
 {
 }
 private bool checkIfValidLicenseType(eLicenseType i_LicenseType)
 {
     return(i_LicenseType == eLicenseType.A || i_LicenseType == eLicenseType.A1 ||
            i_LicenseType == eLicenseType.AA || i_LicenseType == eLicenseType.B);
 }
Example #23
0
 public Bike(VehicleFactory.eVehicleType i_VehicleType, string i_ModelName, string i_LicenseNumber, Tire[] i_Tires, Engine i_Engine, float i_EnergyPercentageLeft, string i_TireManufactureName, float i_TireCurrentAirPressure, eLicenseType i_LicenseType, float i_EngineCapacity)
     : base(i_VehicleType, i_ModelName, i_LicenseNumber, i_Tires, i_Engine, i_EnergyPercentageLeft, i_TireManufactureName, k_MaxAirPressure, i_TireCurrentAirPressure)
 {
     r_LicenseType    = i_LicenseType;
     r_EngineCapacity = i_EngineCapacity;
 }
Example #24
0
        public override void SetListOfMembersToIntialize(int i_MemberIndexInEnum, string i_MemberValue)
        {
            int memberValue;
            eMotorcycleMembersToInitialize vehicleMember = (eMotorcycleMembersToInitialize)i_MemberIndexInEnum;

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

            case eMotorcycleMembersToInitialize.EngineVolume:
            {
                if (int.TryParse(i_MemberValue, out memberValue))
                {
                    if (memberValue <= 0 || memberValue > 2000)
                    {
                        throw new ValueOutOfRangeException(0, 2000, "You entered an invalid input");
                    }
                    else
                    {
                        m_EngineVolume = memberValue;
                    }
                }
                else
                {
                    throw new FormatException("The value is invalid.");
                }

                break;
            }

            case eMotorcycleMembersToInitialize.LicenseType:
            {
                if (checkIfEnumContainThisChoice <eLicenseType>(i_MemberValue, out memberValue))
                {
                    m_LicenseType = (eLicenseType)memberValue;
                }
                else
                {
                    if (int.TryParse(i_MemberValue, out memberValue))
                    {
                        if (Enum.IsDefined(typeof(eLicenseType), memberValue))
                        {
                            m_LicenseType = (eLicenseType)memberValue;
                        }
                        else
                        {
                            throw new ArgumentException("There isn't such license type.");
                        }
                    }
                    else
                    {
                        throw new FormatException("The value is invalid.");
                    }
                }

                break;
            }
            }
        }
Example #25
0
 public MotorCycle(string i_ModelName, string i_LicensePlate, float i_EngineCapacity, eLicenseType i_LicenseType, VehicleEnergy i_VehicleEnergy, string i_Manufacture)
     : base(i_ModelName, i_LicensePlate, i_VehicleEnergy, k_HowManyTires, k_MaxTirePressure, i_Manufacture)
 {
     m_LicenseType      = i_LicenseType;
     m_EngineCapacityCC = i_EngineCapacity;
 }
Example #26
0
        public static bool CheckProperty(Garage i_Garage, string i_Value, string i_Field, string i_Type)
        {
            bool         boolField        = false;
            string       stringField      = "";
            float        floatField       = 0;
            int          intField         = 0;
            eCarDoors    doorField        = eCarDoors.Five;
            eColor       colorField       = eColor.Black;
            eLicenseType licenseTypeField = eLicenseType.A;
            string       colorError       = "This Field must be one of those: " + String.Join(" / ", Enum.GetNames(typeof(eColor)).ToList().Select(x => x.ToString()));
            string       carDoorError     = "This Field must be one of those: " + String.Join(" / ", Enum.GetNames(typeof(eCarDoors)).ToList().Select(x => x.ToString()));
            string       licenseTypeError = "This Field must be one of those: " + String.Join(" / ", Enum.GetNames(typeof(eLicenseType)).ToList().Select(x => x.ToString()));

            switch (i_Type)
            {
            case "int":
                intField = !int.TryParse(i_Value, out intField) ?
                           throw new FormatException("This Field must be a number") :
                                 intField < 0 ? throw new FormatException("Positive number only") : intField;
                break;

            case "eColor":
                colorField = !Enum.IsDefined(typeof(eColor), i_Value) ?
                             throw new FormatException(colorError) : colorField;
                break;

            case "eCarDoors":
                doorField = !Enum.IsDefined(typeof(eCarDoors), i_Value) ?
                            throw new FormatException(carDoorError) : doorField;
                break;

            case "eLicenseType":
                licenseTypeField = !Enum.IsDefined(typeof(eLicenseType), i_Value) ?
                                   throw new FormatException(licenseTypeError) : licenseTypeField;
                break;

            case "bool":
                boolField = !bool.TryParse(i_Value, out boolField) ? throw new FormatException("This Field must be a True of False") : boolField;
                break;

            case "float":
                floatField = !float.TryParse(i_Value, out floatField) ?
                             throw new FormatException("This Field must be a float") :
                                   floatField < 0 ? throw new FormatException("Positive number only") : floatField;
                break;

            case "string":
                if (i_Field == "License Plate")
                {
                    if (i_Garage.IsLicensePlateExists(i_Value))
                    {
                        throw new ArgumentException("There is already a Vehicle with the same license plate");
                    }
                }
                if (i_Value.Replace(" ", "").Length == 0)
                {
                    throw new FormatException("This Field can't be empty");
                }

                break;
            }

            return(true);
        }
 public override void UpdateVehicleData(List <string> i_DataList)
 {
     base.UpdateVehicleData(i_DataList);
     m_LicenseType    = (eLicenseType)int.Parse(i_DataList[4]);
     m_EngineCapacity = int.Parse(i_DataList[5]);
 }
Example #28
0
 public ElectricMotorBike(string i_ModelName, string i_LicenseNumber, float i_RemainingBattery, float i_MaxBattery, int i_EngineCapacity, eLicenseType i_LicenseType)
     : base(i_ModelName, i_LicenseNumber, i_RemainingBattery, i_MaxBattery)
 {
     m_LicenseType    = i_LicenseType;
     m_EngineCapacity = i_EngineCapacity;
 }
Example #29
0
 internal Motorcycle(eLicenseType i_LicenseType, int i_EngineCapacity, string i_ModelName, string i_LicenseNumber, float i_ThePercentageOfEnergyLeft, List <Wheel> i_Wheels) : base(i_ModelName, i_LicenseNumber, i_ThePercentageOfEnergyLeft, i_Wheels)
 {
     m_LicenseType    = i_LicenseType;
     m_EngineCapacity = i_EngineCapacity;
 }
Example #30
0
        public void InsertDetailsOfNewMotorcycle(
            string i_InputVehicleModelName, 
            string i_InputWheelManufacturerName, 
            float i_InputVehicleCurrentAmountOfEnergy, 
            float i_InputWheelCurrentAirPressure, 
            eLicenseType i_InputMotorcycleLicenseType, 
            int i_InputMotorcycleEngineCapacity)
        {
            Motorcycle newMotorcycle = m_Vehicle as Motorcycle;

            if (newMotorcycle != null)
            {
                newMotorcycle.LicenseType = i_InputMotorcycleLicenseType;
                newMotorcycle.EngineCapacity = i_InputMotorcycleEngineCapacity;
                insertDetailsOfNewVehicle(i_InputVehicleModelName, i_InputWheelManufacturerName, i_InputVehicleCurrentAmountOfEnergy, i_InputWheelCurrentAirPressure);
            }
            else
            {
                throw new ArgumentException("The vehicle is not a Motorcycle");
            }
        }
Example #31
0
 public ElectricMotorcycle(string i_LicenseNumber, string i_VehicleModel, List <Wheel> i_WheelsList, eLicenseType i_LicenseType, ElectricEngine i_ElectricEngine)
     : base(i_LicenseNumber, i_VehicleModel, i_WheelsList, i_LicenseType, i_ElectricEngine)
 {
     // Do nothing
 }