Beispiel #1
0
        public static Engine CreateEngine(Vehicle.eVehicleTypes i_VehicleType, float i_EnergyLevel)
        {
            Engine engine = null;

            switch (i_VehicleType)
            {
            case Vehicle.eVehicleTypes.GasMotorcycle:
                engine = new GasEngine(Vehicle.eGasTypes.Octan95, i_EnergyLevel, 5.5f);
                break;

            case Vehicle.eVehicleTypes.ElectricMotorcycle:
                engine = new ElectricEngine(i_EnergyLevel, 2.7f);
                break;

            case Vehicle.eVehicleTypes.GasCar:
                engine = new GasEngine(Vehicle.eGasTypes.Octan98, i_EnergyLevel, 42.0f);
                break;

            case Vehicle.eVehicleTypes.ElectricCar:
                engine = new ElectricEngine(i_EnergyLevel, 2.5f);
                break;

            case Vehicle.eVehicleTypes.Truck:
                engine = new GasEngine(Vehicle.eGasTypes.Octan96, i_EnergyLevel, 135.0f);
                break;
            }

            return(engine);
        }
Beispiel #2
0
        public override void InsertAnswer(string i_UserInput, int i_Index)
        {
            switch (i_Index)
            {
            case 1:
                if (i_UserInput == eEngineTypes.Gas.ToString())
                {
                    m_EnergySource = new GasEngine(eFuelType.Octan98, k_MaxGasEngine);
                }
                else
                {
                    m_EnergySource = new ElectricEngine(k_MaxElectricalEngine);
                }

                break;

            case 2:
                m_NumberOfDoors = (eNumberOfDoors)Enum.Parse(typeof(eNumberOfDoors), i_UserInput);
                break;

            case 3:
                m_CarColor = (eCarColor)Enum.Parse(typeof(eCarColor), i_UserInput);
                break;

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

            default:
                break;
            }
        }
Beispiel #3
0
        public override void SetProperties(string i_Property, string i_Value)
        {
            switch (i_Property)
            {
            case "Vehicle Model":
                ModelName = i_Value;
                break;

            case "Wheels Manufacturer":
                Wheel.SetWheelsManufacturer(Wheels, WheelCount, i_Value);
                break;

            case "Wheels Current Tire Pressure":
                float currentTirePressure = ParsingHelper.ParseToFloatAndThrowProvidedMessage(i_Value, "Wheels Current Tire Pressure must be a number");
                Wheel.SetWheelsCurrentTirePressure(Wheels, WheelCount, currentTirePressure);
                break;

            case "Is Transporting Hazardous Materials?":
                m_IsTransportingHazardousMaterials = checkIsTransportingHazardousMaterials(i_Value);
                break;

            case "Payload Capacity":
                m_PayloadCapacity = ParsingHelper.ParseToFloatAndThrowProvidedMessage(i_Value, "The payload capacity must be a number.");
                break;

            case "Gas Gauge":
                float     gasGauge  = ParsingHelper.ParseToFloatAndThrowProvidedMessage(i_Value, "Gas gauge must be a number.");
                GasEngine GasEngine = Engine as GasEngine;
                GasEngine.GasGague = gasGauge;
                break;
            }
        }
Beispiel #4
0
 public Truck(string i_LicenseNumber, GasEngine i_GasEngine) : base(i_GasEngine, i_LicenseNumber)
 {
     m_NumOfWheels = 16;
     ((GasEngine)MyEngine).MyFuel.FuelType = Fuel.eFuelType.Soler;
     ((GasEngine)MyEngine).MaximumAmountOfFuelInLitters = 120;
     ManageMemberInfo();
 }
Beispiel #5
0
        public Truck(string i_LicensePlateNumber)
        {
            Engine             = new GasEngine(eGasType.Soler, 120);
            LicensePlateNumber = i_LicensePlateNumber;

            WheelCount = 16;
            Wheels     = Wheel.CreateWheelsArray(26, WheelCount);
        }
        internal void ManageEngineMemberInfoStr()
        {
            GasEngine gasEngine = r_Engine as GasEngine;
            Battery   battery   = r_Engine as Battery;

            if (gasEngine != null)
            {
                m_MemberInfoStr.Add(gasEngine.CurrentAmountInfoStr);
            }

            if (battery != null)
            {
                m_MemberInfoStr.Add(battery.RemainingBatteryLifeInfoStr);
            }
        }
Beispiel #7
0
        public void FuelGasVehicle(string i_LicenseNumber, float i_FillFuelQuantity, GasEngine.eGasType i_GasType)
        {
            GasEngine gasEngine = r_Vehicles[i_LicenseNumber].Engine as GasEngine;

            if (gasEngine != null)
            {
                gasEngine.VehicleFueling(i_GasType, i_FillFuelQuantity);
            }
            else
            {
                throw new ArgumentException("Incorrect engine");
            }

            r_Vehicles[i_LicenseNumber].UpdateVehicleEngineEnergyPrecentage();
        }
Beispiel #8
0
        public override void UpdateProperties(List <string> i_UserDialogueInputsList)
        {
            base.UpdateProperties(i_UserDialogueInputsList);
            float currentWheelAirPressure = float.Parse(
                i_UserDialogueInputsList[(int)eVehicleUserDialogueListIndex.CurrentWheelAirPressure]);
            GasEngine gasEngine = m_Engine as GasEngine;

            gasEngine.GasType = GasEngine.eGasType.Soler;
            InitializeWheelsList(
                eNumberOfWheels.Truck,
                i_UserDialogueInputsList[(int)eVehicleUserDialogueListIndex.WheelManufacturer],
                currentWheelAirPressure,
                Wheel.eMaxAirPressure.Truck);
            m_IsCarryingHazardousMaterials =
                i_UserDialogueInputsList[(int)eTruckUserDialogueListIndex.HazardousGoods] == k_Yes; // User inputs "1" for yes, "2" for no
            m_LoadCapacity = float.Parse(i_UserDialogueInputsList[(int)eTruckUserDialogueListIndex.LoadCapacity]);
        }
Beispiel #9
0
        public Car(eTypeOfEngine i_TypeOfEngine, string i_LicensePlateNumber)
        {
            Engine engine = null;

            switch (i_TypeOfEngine)
            {
            case eTypeOfEngine.Gas:
                engine = new GasEngine(eGasType.Octan95, 45);
                break;

            case eTypeOfEngine.Electric:
                engine = new ElectricEngine(3.2f);
                break;
            }

            Engine             = engine;
            LicensePlateNumber = i_LicensePlateNumber;
            WheelCount         = 4;
            Wheels             = Wheel.CreateWheelsArray(32, WheelCount);
        }
Beispiel #10
0
        public override void UpdateProperties(List <string> i_UserDialogueInputsList)
        {
            base.UpdateProperties(i_UserDialogueInputsList);
            float currentWheelAirPressure = float.Parse(
                i_UserDialogueInputsList[(int)eVehicleUserDialogueListIndex.CurrentWheelAirPressure]);
            int       licenseType = int.Parse(i_UserDialogueInputsList[(int)eMotorcycleUserDialogueListIndex.LicenseType]);
            GasEngine gasEngine   = m_Engine as GasEngine;

            if (gasEngine != null)
            {
                gasEngine.GasType = GasEngine.eGasType.Octan95;
            }

            InitializeWheelsList(
                eNumberOfWheels.Truck,
                i_UserDialogueInputsList[(int)eVehicleUserDialogueListIndex.WheelManufacturer],
                currentWheelAirPressure,
                Wheel.eMaxAirPressure.Truck);
            m_EngineCapacity =
                int.Parse(i_UserDialogueInputsList[(int)eMotorcycleUserDialogueListIndex.EngineCapacity]);
            m_LicenseType = (eLicenseType)licenseType;
        }
Beispiel #11
0
        public void VehicleGasRefule(string i_LicenseNumber, Vehicle.eGasTypes i_GasType, float i_GasAmount)
        {
            VehiclesInTheGarage currentVehicleInTheGarage = null;

            if (m_VehiclesInTheGarage.TryGetValue(i_LicenseNumber, out currentVehicleInTheGarage))
            {
                GasEngine gasVehicle = currentVehicleInTheGarage.Vehicle.Engine as GasEngine;

                if (gasVehicle != null)
                {
                    gasVehicle.Refuel(i_GasAmount, i_GasType);
                }
                else
                {
                    throw new ArgumentException("This vehicle needs a different fuel type.");
                }
            }
            else
            {
                throw new ArgumentException("The vehicle is not in the garage.");
            }
        }
Beispiel #12
0
        public override void UpdateProperties(List <string> i_UserDialogueInputsList)
        {
            base.UpdateProperties(i_UserDialogueInputsList);
            float currentWheelAirPressure = float.Parse(
                i_UserDialogueInputsList[(int)eVehicleUserDialogueListIndex.CurrentWheelAirPressure]);
            int       numberOfDoors = int.Parse(i_UserDialogueInputsList[(int)eCarUserDialogueListIndex.NumberOfDoors]);
            int       carColor      = int.Parse(i_UserDialogueInputsList[(int)eCarUserDialogueListIndex.Color]);
            GasEngine gasEngine     = m_Engine as GasEngine;

            if (gasEngine != null)
            {
                gasEngine.GasType = GasEngine.eGasType.Octan96;
            }

            InitializeWheelsList(
                eNumberOfWheels.Car,
                i_UserDialogueInputsList[(int)eVehicleUserDialogueListIndex.WheelManufacturer],
                currentWheelAirPressure,
                Wheel.eMaxAirPressure.Car);
            m_NumberOfDoors = (eNumberOfDoors)numberOfDoors;
            m_CarColor      = (eColor)carColor;
        }
Beispiel #13
0
        public static Vehicle MakeVehicle(int i_VehicleTypeChoice, string i_LicenseNumber)
        {
            Vehicle newVehicle = null;
            Engine  engine     = null;

            switch ((eSupportedVehicles)i_VehicleTypeChoice)
            {
            case eSupportedVehicles.GasMotorbike:
                engine     = new GasEngine(k_GasMotoebikeGasType, k_GasMotorbikeGasTankInLiters);
                newVehicle = new Motorbike(k_GasMotorbikeNumberOfWheels, k_GasMotorbikeMaxAirPreasure, engine, i_LicenseNumber);
                break;

            case eSupportedVehicles.ElectricMotorbike:
                engine     = new ElectricEngine(k_ElectricMotorbikeMaxBatteryInHours);
                newVehicle = new Motorbike(k_ElectricMotorbikeNumberOfWheels, k_ElectricMotorbikeMaxAirPreasure, engine, i_LicenseNumber);
                break;

            case eSupportedVehicles.GasCar:
                engine     = new GasEngine(k_GasCarGasType, k_GasCarGasTankInLiters);
                newVehicle = new Car(k_GasCarNumberOfWheels, k_GasCarMaxAirPreasure, engine, i_LicenseNumber);
                break;

            case eSupportedVehicles.ElectricCar:
                engine     = new ElectricEngine(k_ElectricCarMaxBatteryInHours);
                newVehicle = new Car(k_ElectricCarNumberOfWheels, k_ElectricCarMaxAirPreasure, engine, i_LicenseNumber);
                break;

            case eSupportedVehicles.Truck:
                engine     = new GasEngine(k_TruckGasType, k_TruckGasTankInLiters);
                newVehicle = new Truck(k_TruckNumberOfWheels, k_TruckMaxAirPreasure, engine, i_LicenseNumber);
                break;

            default:
                throw new ArgumentException();
            }

            return(newVehicle);
        }
Beispiel #14
0
        public override void SetProperties(string i_Property, string i_Value)
        {
            switch (i_Property)
            {
            case "Vehicle Model":
                ModelName = i_Value;
                break;

            case "Wheels Manufacturer":
                Wheel.SetWheelsManufacturer(Wheels, WheelCount, i_Value);
                break;

            case "Wheels Current Tire Pressure":
                float currentTirePressure = ParsingHelper.ParseToFloatAndThrowProvidedMessage(i_Value, "Wheels Current Tire Pressure must be a number");
                Wheel.SetWheelsCurrentTirePressure(Wheels, WheelCount, currentTirePressure);
                break;

            case "Car Color":
                CarColor = CheckCarColor(i_Value);
                break;

            case "Doors Count":
                DoorCount = CheckDoorCount(i_Value);
                break;

            case "Gas Gauge":
                float     gasGauge  = ParsingHelper.ParseToFloatAndThrowProvidedMessage(i_Value, "Gas gauge must be a number.");
                GasEngine gasEngine = Engine as GasEngine;
                gasEngine.GasGague = gasGauge;
                break;

            case "Battery Charge":
                float          batteryCharge  = ParsingHelper.ParseToFloatAndThrowProvidedMessage(i_Value, "Battery charge must be a number.");
                ElectricEngine electricEngine = Engine as ElectricEngine;
                electricEngine.BatteryCharge = batteryCharge;
                break;
            }
        }