Пример #1
0
        public void SetValues(List <string> i_ParamsList)
        {
            int numOfValues = GetHowManyParams();

            if (i_ParamsList.Count == numOfValues)
            {
                SetMyValues(i_ParamsList[0], i_ParamsList[1]);
                EnergySource.SetEnergyValues(i_ParamsList[2]);
                SetPrecentageOfEnergy();

                for (int i = 0; i < Wheels.Length; i++)
                {
                    ///Wheels params at indexes 3 and up
                    Wheels[i].SetWheelValues(i_ParamsList[3 + (i * 2)], i_ParamsList[4 + (i * 2)]);
                }
            }
            else if (i_ParamsList.Count < numOfValues)
            {
                throw new FormatException("Not enough parameters were sent.");
            }
            else
            {
                throw new FormatException("Too many parameters were sent.");
            }
        }
Пример #2
0
 public override void SetEnergy(float i_CurrentEnergyAmount)
 {
     EnergySource.MaxEnergy        = (float)Fuel.eFuelTankCapacity.Truck;
     ((Fuel)EnergySource).FuelType = Fuel.eFuelType.Soler;
     EnergySource.FillEnergy(i_CurrentEnergyAmount);
     CalculateEnergyPercent();
 }
Пример #3
0
 internal Vehicle(string i_LicenseNumber)
 {
     r_LicenseNumber = i_LicenseNumber;
     r_Wheels        = new List <Wheel>(0);
     m_ModelName     = null;
     m_EnergySource  = null;
 }
Пример #4
0
 public Vehicle(string i_ModelName, string i_LicenseNumber, List <Wheel> i_Wheels, EnergySource i_EnergySource)
 {
     m_ModelName     = i_ModelName;
     m_LicenseNumber = i_LicenseNumber;
     m_Wheels        = i_Wheels;
     m_EnergySource  = i_EnergySource;
 }
        private static EnergySource CreateEnergySource(VehicleInputData i_VehicleData)
        {
            EnergySource o_energySource = null;

            switch (i_VehicleData.m_VehicleType)
            {
            case eVehicleType.Car:
            case eVehicleType.Motorcycle:
            case eVehicleType.Truck:
                o_energySource = new Fuel(i_VehicleData.m_CurrentFuelCapacity,
                                          i_VehicleData.m_MaxFuelCapacity);
                break;

            case eVehicleType.ElectricCar:
            case eVehicleType.ElectricMotorcycle:
                o_energySource = new Battery(i_VehicleData.m_RemainingBatteryTime,
                                             i_VehicleData.m_MaxBatteryTime);
                break;

            default:
                break;
            }

            return(o_energySource);
        }
        private static EnergySource createEnergySource(VehicleInputData i_VehicleData)
        {
            EnergySource o_energySource = null;

            Fuel.eFuelType fuelType        = 0;
            float          maxFuelCapacity = 0;
            float          maxBatteryTime  = 0;

            switch (i_VehicleData.m_VehicleType)
            {
            case eVehicleType.Car:
                fuelType        = Car.sr_FuelType;
                maxFuelCapacity = Car.sr_MaxFuelCapacity;
                break;

            case eVehicleType.Motorcycle:
                fuelType        = Motorcycle.sr_FuelType;
                maxFuelCapacity = Motorcycle.sr_MaxFuelCapacity;
                break;

            case eVehicleType.Truck:
                fuelType        = Truck.sr_FuelType;
                maxFuelCapacity = Truck.sr_MaxFuelCapacity;
                break;

            case eVehicleType.ElectricCar:
                maxBatteryTime = Car.sr_MaxBatteryTime;
                break;

            case eVehicleType.ElectricMotorcycle:
                maxBatteryTime = Motorcycle.sr_MaxBatteryTime;
                break;

            default:
                break;
            }

            switch (i_VehicleData.m_VehicleType)
            {
            case eVehicleType.Car:
            case eVehicleType.Motorcycle:
            case eVehicleType.Truck:
                o_energySource = new Fuel(i_VehicleData.m_CurrentFuelCapacity,
                                          maxFuelCapacity,
                                          fuelType);
                break;

            case eVehicleType.ElectricCar:
            case eVehicleType.ElectricMotorcycle:
                o_energySource = new Battery(i_VehicleData.m_RemainingBatteryTime,
                                             maxBatteryTime);
                break;

            default:
                break;
            }

            return(o_energySource);
        }
Пример #7
0
 public Vehicle(Vehicle i_Vehicle)
 {
     m_Model         = i_Vehicle.Model;
     m_LicesncePlate = i_Vehicle.LicesncePlate;
     m_EnergyPercent = i_Vehicle.EnergyPercent;
     m_Wheels        = i_Vehicle.m_Wheels;
     m_EnergySource  = i_Vehicle.m_EnergySource;
 }
Пример #8
0
 public Vehicle(string i_Model, string i_LicenseNumber, EnergySource i_EnergySourceType,
     byte i_NumOfWheels, Wheel i_Wheel)
 {
     r_Model = i_Model;
     r_LicenseNumber = i_LicenseNumber;
     m_EnergySourceType = i_EnergySourceType;
     m_energyPercentageLeft = CurrentEnergyPercentage();
     this.addWheelsToVehicle(i_Wheel, i_NumOfWheels);
 }
Пример #9
0
 protected void AllocateEngine(EnergySource.eEnergyType i_EnergySource)
 {
     if (i_EnergySource == EnergySource.eEnergyType.Electric)
     {
         m_Engine = new Electric();
     }
     else
     {
         m_Engine = new Fuel();
     }
 }
Пример #10
0
 public Motorcycle(string i_ModelName,
                   string i_LicenseNumber,
                   List <Wheel> i_Wheels,
                   EnergySource i_EnergySource,
                   eLicenseType i_LicenseType,
                   int i_EngineCapacity)
     : base(i_ModelName, i_LicenseNumber, i_Wheels, i_EnergySource)
 {
     m_LicenseType    = i_LicenseType;
     m_EngineCapacity = i_EngineCapacity;
 }
Пример #11
0
 public Truck(string i_ModelName,
              string i_LicenseNumber,
              List <Wheel> i_Wheels,
              EnergySource i_EnergySource,
              bool i_ContainDangerousSubstances,
              float i_CargoVolume)
     : base(i_ModelName, i_LicenseNumber, i_Wheels, i_EnergySource)
 {
     m_ContainDangerousSubstances = i_ContainDangerousSubstances;
     m_CargoVolume = i_CargoVolume;
 }
Пример #12
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;
 }
Пример #13
0
        public override string GetDetails()
        {
            StringBuilder motorcycleDetails = new StringBuilder();

            motorcycleDetails.AppendFormat("{0}", base.GetDetails());
            motorcycleDetails.AppendFormat("License type: {0}{1}", m_LicenseType.ToString(), Environment.NewLine);
            motorcycleDetails.AppendFormat("Engine displacement: {0}{1}", m_EngineDisplacement.ToString(), Environment.NewLine);
            motorcycleDetails.AppendFormat("{0}{1}", EnergySource.GetEnergySourceDetails(), Environment.NewLine);
            motorcycleDetails.AppendFormat("{0}", GetWheelsDetails());

            return(motorcycleDetails.ToString());
        }
Пример #14
0
        public static Vehicle CreateNewVehicle(eVehicleType i_VehicleType, eEnergySourceType i_EnergySourceType,
                                               float i_CurrentEnergyAmount, string i_VehicleModelName, string i_WheelsManufacturerName,
                                               string i_LicensePlate, float i_CurrentAirPressure,
                                               params object[] i_SpecificVehicleParams)
        {
            VehicleInfo vehicleInfo = getVehicleInfo(i_VehicleType, i_VehicleModelName, i_WheelsManufacturerName,
                                                     i_LicensePlate, i_SpecificVehicleParams);
            EnergySource energySource  = getEnergySource(i_VehicleType, i_EnergySourceType, i_CurrentEnergyAmount);
            Vehicle      resultVehicle = getVehicle(i_VehicleType, vehicleInfo, energySource, i_CurrentAirPressure);

            return(resultVehicle);
        }
Пример #15
0
        public override string GetDetails()
        {
            StringBuilder truckDetails = new StringBuilder();

            truckDetails.AppendFormat("{0}", base.GetDetails());
            truckDetails.AppendFormat("Is carrying hazardous materials: {0}{1}", m_IsCarryingHazardousMaterials.ToString(), Environment.NewLine);
            truckDetails.AppendFormat("Max carrying weight: {0}{1}", m_MaxCarryingWeight.ToString(), Environment.NewLine);
            truckDetails.AppendFormat("{0}{1}", EnergySource.GetEnergySourceDetails(), Environment.NewLine);
            truckDetails.AppendFormat("{0}", GetWheelsDetails());

            return(truckDetails.ToString());
        }
Пример #16
0
        public override string GetDetails()
        {
            StringBuilder carDetails = new StringBuilder();

            carDetails.AppendFormat("{0}", base.GetDetails());
            carDetails.AppendFormat("Color: {0}{1}", m_CarColor.ToString(), Environment.NewLine);
            carDetails.AppendFormat("Number of doors: {0}{1}", m_NumberOfDoors.ToString(), Environment.NewLine);
            carDetails.AppendFormat("{0}{1}", EnergySource.GetEnergySourceDetails(), Environment.NewLine);
            carDetails.AppendFormat("{0}", GetWheelsDetails());

            return(carDetails.ToString());
        }
Пример #17
0
        public Vehicle(
            string i_modelName,
            string i_LicenseNumber,
            int i_NumberOfWheels,
            float i_MaxAirPreasure,
            string i_VehicleType,
            Gas.eFuelType i_fuelType,
            string i_CurrentAmountEnergy,
            float i_TotalAmountOfEnergy,
            string i_WheelManufactor,
            string i_WheelAirPressure)
        {
            r_ModelName     = i_modelName;
            r_LicenseNumber = i_LicenseNumber;
            float currAmountOfEnergy = -1f;
            float currAirPressure;

            EnergySource.eEnergySourceType type;
            try
            {
                currAmountOfEnergy = float.Parse(i_CurrentAmountEnergy);
                type = (EnergySource.eEnergySourceType)Enum.Parse(typeof(EnergySource.eEnergySourceType), i_VehicleType);
            }
            catch (Exception ex)
            {
                throw new FormatException(
                          string.Format(
                              "Error: The field \"{0}\" was not in the right format",
                              currAmountOfEnergy == -1 ? "Fuel Amount" : "Engine Type"),
                          ex);
            }

            if (!float.TryParse(i_WheelAirPressure, out currAirPressure) || currAirPressure > i_MaxAirPreasure)
            {
                throw new FormatException(string.Format("Error: could not assign {0} as current air pressure", i_WheelAirPressure));
            }

            if (type == EnergySource.eEnergySourceType.Gas)
            {
                m_EnergySource = new Gas(currAmountOfEnergy, i_TotalAmountOfEnergy, i_fuelType);
            }
            else
            {
                m_EnergySource = new Electric(currAmountOfEnergy, i_TotalAmountOfEnergy);
            }

            m_VehicleWheels = new List <Wheel>();
            for (int i = 0; i < i_NumberOfWheels; i++)
            {
                m_VehicleWheels.Add(new Wheel(i_MaxAirPreasure, i_WheelManufactor, currAirPressure));
            }
        }
Пример #18
0
        /// <summary>
        /// This method inherited from EnergySource class, loads electric battery type of energy
        /// </summary>
        /// <param name="i_AmountOfEnergyToAdd"> Amount of electric battery energy to add </param>
        /// <param name="i_EnergySourceToAdd"> Type of energy source </param>
        /// <exception cref="System.Exception.ValueOutOfRangeException">Thrown when adding more energy source then the max</exception>
        /// <exception cref="System.Exception.FormatException">Thrown when the energy source adding paramater is not electric battery</exception>
        public override void LoadEnergySource(float i_AmountOfEnergyToAdd, EnergySource i_EnergySourceToAdd)
        {
            ElectricBattery myElectricBattery = i_EnergySourceToAdd as ElectricBattery;

            if (myElectricBattery != null)
            {
                CurrentAmountOfEnergy += i_AmountOfEnergyToAdd;
            }
            else
            {
                throw new FormatException("The vehicle's energy source is not electric");
            }
        }
Пример #19
0
 public Truck(
     string i_ModelName,
     string i_LicensePlate,
     float i_EnergyPercentage,
     Wheel[] i_Wheels,
     EnergySource i_EnergySource,
     bool i_IsCarrageDangerous,
     float i_CarriageCapacity) :
     base(i_ModelName, i_LicensePlate, i_EnergyPercentage, i_Wheels, i_EnergySource)
 {
     v_IsCarriageDangerous = i_IsCarrageDangerous;
     m_CarriageCapacity    = i_CarriageCapacity;
 }
Пример #20
0
 public Car(string i_model, string i_plateNumber, eCarColor i_carColor, int i_carDoors, float i_CurrentCapacityEnergy, ref List <Wheel> io_Wheels, bool i_IsElectronic) : base(i_model, i_plateNumber, ref io_Wheels)
 {
     m_Color       = i_carColor;
     m_DoorsNumber = i_carDoors;
     if (i_IsElectronic)
     {
         m_EnergySource = new Electronic(3.2f, i_CurrentCapacityEnergy);
     }
     else
     {
         m_EnergySource = new Fuel(eFuelKinds.Octan98, 45f, i_CurrentCapacityEnergy);
     }
 }
Пример #21
0
 public Motorcycle(
     string i_ModelName,
     string i_LicensePlate,
     float i_EnergyPercentage,
     Wheel[] i_Wheels,
     EnergySource i_EnergySource,
     eLicenseType i_LicenseType,
     int i_EngineVolume) :
     base(i_ModelName, i_LicensePlate, i_EnergyPercentage, i_Wheels, i_EnergySource)
 {
     m_LicenseType  = i_LicenseType;
     m_EngineVolume = i_EngineVolume;
 }
Пример #22
0
        public MotorCycle(string i_Model, string i_PlateNumber, int i_EngineValume, eMotorCycleLicences i_MotorCycleLicences, float i_CurrentCapacityEnergy, ref List <Wheel> io_Wheels, bool i_IsElectronic) : base(i_Model, i_PlateNumber, ref io_Wheels)
        {
            m_EngineValume  = i_EngineValume;
            m_KingOfLicence = i_MotorCycleLicences;

            if (i_IsElectronic)
            {
                m_EnergySource = new Electronic(1.8f, i_CurrentCapacityEnergy);
            }

            else
            {
                m_EnergySource = new Fuel(eFuelKinds.Octan96, 6f, i_CurrentCapacityEnergy);
            }
        }
Пример #23
0
        public Vehicle(string i_LicenceNumber, string i_ModelName, EnergySource.eTypeOfEnergySource i_Source)
        {
            r_ModelName          = i_ModelName;
            r_LicenceNumber      = i_LicenceNumber;
            r_CollectionOfWheels = new List <Wheel>();

            if (i_Source == EnergySource.eTypeOfEnergySource.Battery)
            {
                r_EnergySource = new Battery();
            }
            else
            {
                r_EnergySource = new Fuel();
            }
        }
Пример #24
0
        public Vehicle(string i_ModelName, string i_LicensePlate, EnergySource.eSource i_Source)
        {
            m_ModelName     = i_ModelName;
            m_LicenseNumber = i_LicensePlate;
            m_Wheels        = new List <Wheel>();

            if (i_Source == EnergySource.eSource.ElectricSource)
            {
                m_EnergySource = new ElectricSource();
            }
            else
            {
                m_EnergySource = new FuelSource();
            }
        }
Пример #25
0
        public Vehicle(string i_LicensePlate, string i_ModelName, EnergySource.eSource i_Source)
        {
            m_ModelName    = i_ModelName;
            m_LicensePlate = i_LicensePlate;
            m_Wheels       = new List <Wheel>();

            if (i_Source == EnergySource.eSource.Battery)
            {
                m_EnergySource = new Battery();
            }
            else
            {
                m_EnergySource = new GasTank();
            }
        }
Пример #26
0
        public override void SetEnergy(float i_CurrentEnergyAmount)
        {
            if (EnergySource is Fuel)
            {
                EnergySource.MaxEnergy        = (float)Fuel.eFuelTankCapacity.Car;
                ((Fuel)EnergySource).FuelType = Fuel.eFuelType.Octan96;
                EnergySource.FillEnergy(i_CurrentEnergyAmount);
            }
            else
            {
                EnergySource.MaxEnergy = k_MaxBatteryCapacity;
                EnergySource.FillEnergy(i_CurrentEnergyAmount / 60);
            }

            CalculateEnergyPercent();
        }
Пример #27
0
        public Vehicle(string i_ModelName, string i_LicenseNumber, EnergySource.eSourceType i_EnergySource)
        {
            m_ModelName     = i_ModelName;
            m_LicenseNumber = i_LicenseNumber;

            if (i_EnergySource.Equals(EnergySource.eSourceType.Gas))
            {
                m_EnergySource = new GasTank();
            }
            else
            {
                m_EnergySource = new Battery();
            }

            m_Wheels = new List <Wheel>();
        }
Пример #28
0
        public override string GetVehicleParamsNeeds()
        {
            string whatINeedMsg, wheelsNeedsMsg, energyNeedsMsg;

            energyNeedsMsg = EnergySource.GetEnergySourceParamsNeeds();
            wheelsNeedsMsg = "4 wheels information: Model name, current amount of air";

            whatINeedMsg = string.Format(
                @"Car color
Num of doors
{0}
{1}",
                energyNeedsMsg,
                wheelsNeedsMsg);

            return(whatINeedMsg);
        }
Пример #29
0
        public override string GetVehicleParamsNeeds()
        {
            string whatINeedMsg, wheelsNeedsMsg, energyNeedsMsg;

            energyNeedsMsg = EnergySource.GetEnergySourceParamsNeeds();
            wheelsNeedsMsg = "12 wheels information: Model name, current amount of air";

            whatINeedMsg = string.Format(
                @"Is carrying dangerous materials (True/False)
Volume of cargo
{0}
{1}",
                energyNeedsMsg,
                wheelsNeedsMsg);

            return(whatINeedMsg);
        }
Пример #30
0
        public Vehicle(string i_LicesncePlate, eEnergyType i_SouceType)
        {
            m_LicesncePlate = i_LicesncePlate;
            switch (i_SouceType)
            {
            case eEnergyType.Electric:
                m_EnergySource = new ElectricEnergySource();
                break;

            case eEnergyType.Fuel:
                m_EnergySource = new FuelEnergySource();
                break;

            default:
                break;
            }
        }
Пример #31
0
        public override string GetVehicleParamsNeeds()
        {
            string whatINeedMsg, wheelsNeedsMsg, energyNeedsMsg;

            energyNeedsMsg = EnergySource.GetEnergySourceParamsNeeds();
            wheelsNeedsMsg = "2 wheels information: Model name, current amount of air";

            whatINeedMsg = string.Format(
                @"License type
Engine capacity
{0}
{1}",
                energyNeedsMsg,
                wheelsNeedsMsg);

            return(whatINeedMsg);
        }
Пример #32
0
 protected Vehicle(string i_Manufacturer, string i_PlateLicenseNumber, float i_RemainingEnergyPrecentage,
                   int i_NumberOfWheels, float i_MaxAirPressure, EnergySource.eEnergySourceType i_EnergyType,
                   string i_WheelsManufacturName, float i_WheelsCurrentAirPressurePrecentage)
 {
     m_ManufacturName     = i_Manufacturer;
     m_PlateLicenseNumber = i_PlateLicenseNumber;
     m_Wheels             = new List <Wheel>(i_NumberOfWheels);
     setWheels(i_WheelsManufacturName, i_WheelsCurrentAirPressurePrecentage, i_MaxAirPressure, i_NumberOfWheels);
     if (i_EnergyType == EnergySource.eEnergySourceType.Fuel)
     {
         m_EnergySource = new FuelTank();
     }
     else
     {
         m_EnergySource = new ElectricBattery();
     }
     setEnergySource(i_RemainingEnergyPrecentage);
 }
Пример #33
0
        /// <summary>
        /// This method inherited from EnergySource class, fueling the vehicle 
        /// </summary>
        /// <param name="i_AmountOfEnergyToAdd"> Amount of fuel to add </param>
        /// <param name="i_EnergySourceToAdd"> Type of energy source </param>
        /// <exception cref="System.Exception.ValueOutOfRangeException">Thrown when adding more energy source then the max</exception>
        /// <exception cref="System.Exception.FormatException">Thrown when the energy source adding paramater is not fuel</exception>
        public override void LoadEnergySource(float i_AmountOfEnergyToAdd, EnergySource i_EnergySourceToAdd)
        {
            Fuel myFuel = i_EnergySourceToAdd as Fuel;

            if (myFuel != null)
            {
                if (myFuel.FuelType == m_eFuelType)
                {
                    CurrentAmountOfEnergy += i_AmountOfEnergyToAdd;
                }
                else
                {
                    throw new ArgumentException("The fuel type for reffil is unsuitable");
                }
            }
            else
            {
                throw new FormatException("The vehicle's energy source is not fuel");
            }
        }
Пример #34
0
 public Truck(EnergySource i_EnergySource)
     : base(i_EnergySource)
 {
     Wheels = new Wheel[10];
 }
Пример #35
0
 public abstract void LoadEnergySource(float i_AmountOfEnergyToAdd, EnergySource i_EnergySourceToAdd);
Пример #36
0
 /// <summary>
 /// Loads vehicle with energy source by using the method LoadEnergySource of class EnergySource
 /// </summary>
 /// <param name="i_AmountOfEnergyToAdd">Amount of energy source</param>
 /// <param name="i_EnergySource">Type of energy source</param>
 public void LoadEnergy(float i_AmountOfEnergyToAdd, EnergySource i_EnergySource)
 {
     m_VehicleEnergySource.LoadEnergySource(i_AmountOfEnergyToAdd, i_EnergySource);
     SetCurrentAmountEnergySourceInPercentage();
 }
Пример #37
0
 public Car(EnergySource i_EnergySource)
     : base(i_EnergySource)
 {
     Wheels = new Wheel[4];
 }
Пример #38
0
 public Vehicle(EnergySource i_CurrentEnergySource)
 {
     VehicleEnergySource = i_CurrentEnergySource;
 }
Пример #39
0
 public Motorcycle(EnergySource i_EnergySource)
     : base(i_EnergySource)
 {
     Wheels = new Wheel[2];
 }
Пример #40
0
 public Motorcycle(string i_Model, string i_LicenseNumber, EnergySource i_EnergySourceType
     , byte i_NumOfWheels, Wheel i_Wheel)
     : base(i_Model, i_LicenseNumber, i_EnergySourceType, i_NumOfWheels, i_Wheel)
 {
 }