Exemplo n.º 1
0
 public Bike(
     Owner i_Owner, string i_Model, string i_LicenceNumber, Tank i_Tank, Wheel[] i_Wheels, eLicenceType i_LicenceType, int i_EngineVolume)
     : base(i_Owner, i_Model, i_LicenceNumber, i_Tank, i_Wheels)
 {
     m_LicenceType  = i_LicenceType;
     m_EngineVolume = i_EngineVolume;
 }
Exemplo n.º 2
0
        public override void InsertAnswer(string i_UserInput, int i_Index)
        {
            switch (i_Index)
            {
            case 1:
                if (i_UserInput == "Gas")
                {
                    this.m_EnergySource = new GasEngine(eFuelType.Octan95, k_MaxGasEngine);
                }
                else
                {
                    this.m_EnergySource = new ElectricEngine(k_MaxElectricalEngine);
                }

                break;

            case 2:
                m_LicenceType = (eLicenceType)Enum.Parse(typeof(eLicenceType), i_UserInput);
                break;

            case 3:
                EngineSize = int.Parse(i_UserInput);
                break;

            case 4:
                m_EnergySource.CurrentEnergy = float.Parse(i_UserInput);
                break;

            default:
                break;
            }
        }
Exemplo n.º 3
0
        public static string StringFromType(eLicenceType i_LicenceType)
        {
            string result;

            switch (i_LicenceType)
            {
            case eLicenceType.A1:
                result = "A1 Licence";
                break;

            case eLicenceType.AA:
                result = "AA Licence";
                break;

            case eLicenceType.AB:
                result = "AB Licence";
                break;

            case eLicenceType.C:
                result = "C Licence";
                break;

            default:
                throw new ArgumentException("Unknown licence type");
            }

            return(result);
        }
Exemplo n.º 4
0
 public MotorBike(string i_ModelName, string i_LicenceID, eLicenceType i_LicenceType, int i_EngineCapacity, string i_WheelsManfacturer) :
     base(i_ModelName, i_LicenceID)
 {
     r_LicenceType    = i_LicenceType;
     r_EngineCapacity = i_EngineCapacity;
     createVehicleWheels(k_MaxAirPressureForBike, i_WheelsManfacturer, k_NumberOfWheels);
 }
Exemplo n.º 5
0
 public Motorcycle(string i_ModuleName, string i_LicensePlate, eLicenceType i_LicenceType,
                   int i_EngineVolume, List <Wheel> i_Wheels, PowerSource i_PowerSource)
     : base(i_ModuleName, i_LicensePlate, i_Wheels, i_PowerSource, 2)
 {
     m_LicenceType  = i_LicenceType;
     m_EngineVolume = i_EngineVolume;
 }
        public override void InitializeVehicleWithAdditionalProps(string i_PathOfFileWithValuesToClassMembers)
        {
            string[] valsForMembers = File.ReadAllLines(i_PathOfFileWithValuesToClassMembers);

            //[0] is licence type:
            m_LicenceType = getLicenceTypeFromStr(valsForMembers[0]);
            //[1] is engine capacity
            int.TryParse(valsForMembers[1], out m_EngineCapacity);
        }
Exemplo n.º 7
0
        public static Vehicle createVehicleFromType(eVehicleType i_VehicletoCreate, string i_ModelName, string i_LicenceID, object i_UniqueParameter1, object i_UniqueParameter2, string i_WheelsManfacturer, float i_AmountOfCurrentEnergyLeft)
        {
            Vehicle newVehicle = new Vehicle(i_ModelName, i_LicenceID);

            if ((i_VehicletoCreate == eVehicleType.FuelMotorBike) || (i_VehicletoCreate == eVehicleType.ElectricMotorBike))
            {
                eLicenceType licenceID      = (eLicenceType)i_UniqueParameter1;
                int          engineCapacity = (int)i_UniqueParameter2;
                if (i_VehicletoCreate == eVehicleType.FuelMotorBike)
                {
                    FuelMotorBike newFuelMotorBike = new FuelMotorBike(i_ModelName, i_LicenceID, licenceID, engineCapacity, i_WheelsManfacturer, i_AmountOfCurrentEnergyLeft);
                    newVehicle = newFuelMotorBike;
                    newVehicle = newVehicle as FuelMotorBike;
                }
                else
                {
                    ElectricMotorBike newElectricMotorBike = new ElectricMotorBike(i_ModelName, i_LicenceID, licenceID, engineCapacity, i_WheelsManfacturer, i_AmountOfCurrentEnergyLeft);
                    newVehicle = newElectricMotorBike;
                    newVehicle = newVehicle as ElectricMotorBike;
                }
            }
            else if ((i_VehicletoCreate == eVehicleType.FuelCar) || (i_VehicletoCreate == eVehicleType.ElectricCar))
            {
                eCarColor    carColor    = (eCarColor)i_UniqueParameter1;
                eDoorsAmount doorsAmount = (eDoorsAmount)i_UniqueParameter2;
                if (i_VehicletoCreate == eVehicleType.FuelCar)
                {
                    FuelCar newFuelCar = new FuelCar(i_ModelName, i_LicenceID, carColor, doorsAmount, i_WheelsManfacturer, i_AmountOfCurrentEnergyLeft);
                    newVehicle = newFuelCar;
                    newVehicle = newVehicle as FuelCar;
                }
                else
                {
                    ElectricCar newElectricCar = new ElectricCar(i_ModelName, i_LicenceID, carColor, doorsAmount, i_WheelsManfacturer, i_AmountOfCurrentEnergyLeft);
                    newVehicle = newElectricCar;
                    newVehicle = newVehicle as ElectricCar;
                }
            }
            else if (i_VehicletoCreate == eVehicleType.Truck)
            {
                bool  carryingToxic = (bool)i_UniqueParameter1;
                float loadVolume    = (float)i_UniqueParameter2;
                Truck newTruck      = new Truck(i_ModelName, i_LicenceID, carryingToxic, loadVolume, i_WheelsManfacturer, i_AmountOfCurrentEnergyLeft);
                newVehicle = newTruck;
                newVehicle = newVehicle as Truck;
            }
            else
            {
                throw new ArgumentException();
            }
            if (newVehicle == null)
            {
                throw new FormatException();
            }
            return(newVehicle);
        }
        private eLicenceType getLicenceTypeFromStr(string i_ValStr)
        {
            eLicenceType licence = new eLicenceType();

            if (!Enum.TryParse(i_ValStr.ToUpper(), out licence))
            {
                throw new ArgumentException("No such licence option!");
            }

            return(licence);
        }
        public static Component ParseLicenceType()
        {
            Console.WriteLine("Choose licence type: ");
            Console.WriteLine("1. A1");
            Console.WriteLine("2. AA");
            Console.WriteLine("3. AB");
            Console.WriteLine("4. C");

            int          result  = ParseIntWithinRange(1, 4);
            eLicenceType licType = (eLicenceType)result;

            return(new LicenceComponent(licType));
        }
Exemplo n.º 10
0
        public void SetLicenceType(string i_LicenceType)
        {
            eLicenceType licenceTypeAsEnum;
            string       licenceTypeFormatted = char.ToUpper(i_LicenceType[0]) + i_LicenceType.Substring(1);

            try
            {
                licenceTypeAsEnum = (eLicenceType)Enum.Parse(typeof(eLicenceType), licenceTypeFormatted);
            }
            catch
            {
                throw new ArgumentException("Error: licence type must be A, A1, A2 or B}");
            }

            m_LicenceType = licenceTypeAsEnum;
        }
Exemplo n.º 11
0
        public override void ParseNeededInput(Dictionary <string, string> i_InputToParse)
        {
            string licenceType;
            string engineCapacityInput;
            int    engineCapacityCCM = -1;

            if (!i_InputToParse.TryGetValue(sr_LicenceTypeKey, out licenceType))
            {
                throw new FormatException("No Licence Type");
            }

            if (!((i_InputToParse.TryGetValue(sr_EngineCapacityKey, out engineCapacityInput)) &&
                  (int.TryParse(engineCapacityInput, out engineCapacityCCM))))
            {
                throw new FormatException("No Engine Capacity");
            }

            if (engineCapacityCCM < 0)
            {
                throw new ArgumentException("Engine capacity must be positive");
            }

            switch (licenceType)
            {
            case "A":
                this.m_LicenceType = eLicenceType.A;
                break;

            case "AB":
                this.m_LicenceType = eLicenceType.AB;
                break;

            case "A2":
                this.m_LicenceType = eLicenceType.A2;
                break;

            case "B1":
                this.m_LicenceType = eLicenceType.B1;
                break;

            default:
                throw new ArgumentException("Invalid licence type");
            }

            this.m_EngineCapacity = engineCapacityCCM;
        }
Exemplo n.º 12
0
        public void UpdateNewMotorcycleInput(int i_LicenceType, int i_EngineDisplacement)
        {
            m_EngineDisplacement = i_EngineDisplacement;
            switch (i_LicenceType)
            {
            case 1:
                m_LicenceType = eLicenceType.A;
                break;

            case 2:
                m_LicenceType = eLicenceType.A1;
                break;

            case 3:
                m_LicenceType = eLicenceType.A2;
                break;

            case 4:
                m_LicenceType = eLicenceType.B;
                break;
            }
        }
Exemplo n.º 13
0
        public override void InitializeArguments()
        {
            base.InitializeArguments();
            Energy.MaxCapacity = m_MaximumEnergyCapacity;
            m_LicenceType      = (eLicenceType)Enum.Parse(typeof(eLicenceType),
                                                          m_Questioning[(int)eIndexListQuestioningExtras.LicenceType].Answer);
            m_EnergyCapacity = int.Parse(m_Questioning[(int)eIndexListQuestioningExtras.EnergyCapacity].Answer);

            foreach (Wheel currentWheel in Wheels)
            {
                if (float.Parse(m_Questioning[(int)eIndexListQuestioning.WheelMaxAirPressure].Answer) >
                    k_MaximumAirPressure)
                {
                    throw new ArgumentException("Wheel maximum pressure is bigger than the motorcycle support");
                }
                else
                {
                    currentWheel.Initialize(m_Questioning[(int)eIndexListQuestioning.WheelsManufecturer].Answer,
                                            float.Parse(m_Questioning[(int)eIndexListQuestioning.WheelMaxAirPressure].Answer),
                                            float.Parse(m_Questioning[(int)eIndexListQuestioning.WheelCurrentAirPressure].Answer));
                }
            }
        }
Exemplo n.º 14
0
 public FuelMotorBike(string i_ModelName, string i_LicenceID, eLicenceType i_LicenceType, int i_EngineCapacity, string i_WheelsManfacturer, float i_AmountOfCurrentFuelInLitters) :
     base(i_ModelName, i_LicenceID, i_LicenceType, i_EngineCapacity, i_WheelsManfacturer)
 {
     asssaignEnergySourceToFuel(ref EnergySourceByRef, k_TypefOfFuel, i_AmountOfCurrentFuelInLitters, k_MaxFuelInLitters, EnergyType.Fuel);
 }
 public ElectronicBike(
     Owner i_Owner, string i_Model, string i_LicenceNumber, ElectronicTank i_ElectronicTank, Wheel[] i_Wheels, eLicenceType i_LicenceType, int i_EngineVolume)
     : base(i_Owner, i_Model, i_LicenceNumber, i_ElectronicTank, i_Wheels, i_LicenceType, i_EngineVolume)
 {
 }
Exemplo n.º 16
0
        public static string StringFromType(eLicenceType i_LicenceType)
        {
            string result;

            switch (i_LicenceType)
            {
                case eLicenceType.A1:
                    result = "A1 Licence";
                    break;
                    case eLicenceType.AA:
                    result = "AA Licence";
                    break;
                    case eLicenceType.AB:
                    result = "AB Licence";
                    break;
                    case eLicenceType.C:
                    result = "C Licence";
                    break;
                default:
                    throw new ArgumentException("Unknown licence type");
            }

            return result;
        }
Exemplo n.º 17
0
 public MotorCycle(string i_ModelName, string i_LicenceId, string i_WheelManufacturerName, float i_MaxWheelPressureManufacturerSuggested, int i_NumberOfWheels, VehicleType.eVehicleType i_VehicleType, string i_StrMotorCycleLicenceType, string i_StrMotorCycleEngineCapacity, params string[] i_DataToFillEnergySource)
     : base(i_ModelName, i_LicenceId, i_WheelManufacturerName, i_MaxWheelPressureManufacturerSuggested, i_NumberOfWheels, i_VehicleType, i_DataToFillEnergySource)
 {
     m_MotorCycleLicenceType    = (eLicenceType)Enum.Parse(typeof(eLicenceType), i_StrMotorCycleLicenceType);
     m_MotorCycleEngineCapacity = int.Parse(i_StrMotorCycleEngineCapacity);
 }
Exemplo n.º 18
0
 //-------------------------------------------------------------------------//
 //                                Constructor                              //
 //-------------------------------------------------------------------------//
 public Motorcycle(eLicenceType i_LicenseType, int i_EngineCapacity)
 {
     m_EngineCapacity = i_EngineCapacity;
     m_LicenceType    = i_LicenseType;
 }
 public LicenceComponent(eLicenceType i_Value)
 {
     r_Licence       = i_Value;
     m_ComponentType = eComponentType.LicenceComponent;
 }
 public LicenceComponent(eLicenceType i_Value)
 {
     r_Licence = i_Value;
     m_ComponentType = eComponentType.LicenceComponent;
 }
Exemplo n.º 21
0
 public GasBike(
     Owner i_Owner, string i_Model, string i_LicenceNumber, GasTank i_GasTank, Wheel[] i_Wheels, eLicenceType i_LicenceType, int i_EngineVolume)
     : base(i_Owner, i_Model, i_LicenceNumber, i_GasTank, i_Wheels, i_LicenceType, i_EngineVolume)
 {
 }
Exemplo n.º 22
0
 public ElectricMotorBike(string i_ModelName, string i_LicenceID, eLicenceType i_LicenceType, int i_EngineCapacity, string i_WheelsManfacturer, float i_AmountOfCurrentBattryLeft) :
     base(i_ModelName, i_LicenceID, i_LicenceType, i_EngineCapacity, i_WheelsManfacturer)
 {
     asssaignEnergySourceToElectric(ref EnergySourceByRef, i_AmountOfCurrentBattryLeft, k_MaxBatteryTime, EnergyType.Electric);
 }