Exemplo n.º 1
0
        public static Truck CreateTruck(string i_LicensePlate, string i_Model, Dictionary <eVehicleData, string> i_DataMemory, Dictionary <Vehicle.eWheelData, string> i_Wheel, Energy.eEnergyType i_EnergyType)
        {
            checkNumericStrings(i_DataMemory[eVehicleData.CargoVolume], i_DataMemory[eVehicleData.AmountOfFuelLeft]);
            bool  isHavingHazardousMeterials = Truck.parseHazardousMeterials(i_DataMemory[eVehicleData.HavingHazardousMeterials]);
            float cargoVolume = float.Parse(i_DataMemory[eVehicleData.CargoVolume]);

            Energy energyType = new RegularEnergy(RegularEnergy.eFuelType.Soler, float.Parse(i_DataMemory[eVehicleData.AmountOfFuelLeft]), k_RegularTruckFullTank);

            return(new Truck(isHavingHazardousMeterials, cargoVolume, i_Model, i_LicensePlate, i_Wheel, energyType));
        }
Exemplo n.º 2
0
        public static Motorcycle CreateMotorCycle(string i_LicensePlate, string i_Model, Dictionary <eVehicleData, string> i_DataMemory, Dictionary <Vehicle.eWheelData, string> i_Wheel, Energy.eEnergyType i_EnergyType)
        {
            checkNumericStrings(i_DataMemory[eVehicleData.EngineCapacity]);
            Motorcycle.eLicenseType licenceType = Motorcycle.parseLicenseType(i_DataMemory[eVehicleData.LicenceType]);
            int    engineCapacity = int.Parse(i_DataMemory[eVehicleData.EngineCapacity]);
            Energy energyType     = null;

            if (i_EnergyType == Energy.eEnergyType.Regular)
            {
                checkNumericStrings(i_DataMemory[eVehicleData.AmountOfFuelLeft]);
                energyType = new RegularEnergy(RegularEnergy.eFuelType.Octan95, float.Parse(i_DataMemory[eVehicleData.AmountOfFuelLeft]), k_RegularMotorcycleFullTank);
            }
            else if (i_EnergyType == Energy.eEnergyType.Electric)
            {
                checkNumericStrings(i_DataMemory[eVehicleData.HoursLeftInBattery]);
                energyType = new ElectricEnergy(float.Parse(i_DataMemory[eVehicleData.HoursLeftInBattery]), k_ElectricMotorcycleMaxBatteryHourTime);
            }

            return(new Motorcycle(licenceType, engineCapacity, i_Model, i_LicensePlate, i_Wheel, energyType));
        }
Exemplo n.º 3
0
        public static Car CreateCar(string i_LicensePlate, string i_Model, Dictionary <eVehicleData, string> i_DataMemory, Dictionary <Vehicle.eWheelData, string> i_Wheel, Energy.eEnergyType i_EnergyType)
        {
            checkNumericStrings(i_DataMemory[eVehicleData.NumOfDoors]);
            Car.eColorType color      = Car.parseColor(i_DataMemory[eVehicleData.Color]);
            int            numOfDoors = Car.parseNumOfDoors(i_DataMemory[eVehicleData.NumOfDoors]);
            Energy         energyType = null;

            if (i_EnergyType == Energy.eEnergyType.Regular)
            {
                checkNumericStrings(i_DataMemory[eVehicleData.AmountOfFuelLeft]);
                energyType = new RegularEnergy(RegularEnergy.eFuelType.Octan96, float.Parse(i_DataMemory[eVehicleData.AmountOfFuelLeft]), k_RegualrCarFullTank);
            }
            else if (i_EnergyType == Energy.eEnergyType.Electric)
            {
                checkNumericStrings(i_DataMemory[eVehicleData.HoursLeftInBattery]);
                energyType = new ElectricEnergy(float.Parse(i_DataMemory[eVehicleData.HoursLeftInBattery]), k_ElectricCarMaxBatteryHourTime);
            }

            return(new Car(color, numOfDoors, i_Model, i_LicensePlate, i_Wheel, energyType));
        }
        public void FuelRegularVehicle(string i_LicenseNumber, string i_FuelType, string i_AmountToFuel)
        {
            RegularEnergy vehicleEnergy = m_VehiclesInGarage[i_LicenseNumber].Vehicle.Energy as RegularEnergy;

            RegularEnergy.eFuelType fuelType = RegularEnergy.parseFuelType(i_FuelType);
            float amountToFuel;
            bool  res = float.TryParse(i_AmountToFuel, out amountToFuel);

            if (vehicleEnergy == null)
            {
                throw new ArgumentException("The vehicle isn't using Fuel");
            }

            if (res && vehicleEnergy.r_FuleType == fuelType)
            {
                vehicleEnergy.fuel(amountToFuel);
                m_VehiclesInGarage[i_LicenseNumber].Vehicle.updatePecentageOfEnergy();
            }
            else
            {
                throw new ArgumentException("Wrong type of fuel for fueling");
            }
        }