コード例 #1
0
 public static void ValidateFuelType(EnergyType i_Energy)
 {
     if (!(i_Energy == EnergyType.Fuel))
     {
         throw new ArgumentException();
     }
 }
コード例 #2
0
 public Truck(string i_Model, string i_LicenseNumber, EnergyType i_SourceOfEnergy, Wheel i_Wheel)
     : base(i_Model, i_LicenseNumber, i_SourceOfEnergy)
 {
     AddWheels(i_Wheel, k_NumOfWheels, Wheel.eMaxAirPressure.Truck);
     EnergySetup(i_SourceOfEnergy);
     m_IsDangerous = false;
 }
コード例 #3
0
ファイル: Vehicle.cs プロジェクト: naorpa/GrageProject
 public Vehicle(string i_Model, string i_LicenseNumber, EnergyType i_SourceOfEnergy)
 {
     r_Model         = i_Model;
     r_LicenseNumber = i_LicenseNumber;
     r_Wheels        = new List <Wheel>();
     m_Source        = i_SourceOfEnergy;
 }
コード例 #4
0
ファイル: MotorCycle.cs プロジェクト: amirnad/CSharp_Garage
 public Motorcycle(eLicenseTypes o_LicenseType, int o_EngineVolume, EnergyType o_TypeOfEnergy, string o_ModelName, string o_LicensePlate, OwnerDetails o_MotorcycleOwner, List <Wheel> o_Wheels)
     : base(o_ModelName, o_LicensePlate, o_MotorcycleOwner, o_Wheels)
 {
     m_licenseType  = o_LicenseType;
     m_engineVolume = o_EngineVolume;
     m_EnergyType   = o_TypeOfEnergy;
     EnergyRatio    = o_TypeOfEnergy.CalculateRatio();
 }
コード例 #5
0
 //WE will pass Fuel as i_EnergyType then the base constrctour will set the energy to fuel,
 public Truck(string i_m_ModelName, string i_LicenseNumber,
              List <Wheels> i_ListOfWheels, EnergyType i_EnergyType,
              float i_CarGoCapcity, bool i_ContainsDangerousMaterials)
     : base(i_m_ModelName, i_LicenseNumber, i_ListOfWheels, i_EnergyType)
 {
     this.r_CarGoCapcity = i_CarGoCapcity;
     this.r_ContainsDangerousMaterials = i_ContainsDangerousMaterials;
 }
コード例 #6
0
 internal Car(string i_m_ModelName, string i_LicenseNumber,
              List <Wheels> i_ListOfWheels, EnergyType i_EnergyType,
              eNumberOfDoors i_NumberOfDoors, eCarColor i_CarColor)
     : base(i_m_ModelName, i_LicenseNumber, i_ListOfWheels, i_EnergyType)
 {
     this.r_CarColor      = i_CarColor;
     this.r_NumberOfDoors = i_NumberOfDoors;
 }
コード例 #7
0
ファイル: Car.cs プロジェクト: amirnad/CSharp_Garage
 public Car(eCarColors i_ChosenColor, eNumberOfDoors i_CarDoors, EnergyType o_TypeOfEnergy, string o_ModelName, string o_LicensePlate, OwnerDetails o_CarOwner, List <Wheel> o_Wheels)
     : base(o_ModelName, o_LicensePlate, o_CarOwner, o_Wheels)
 {
     m_CarColor      = i_ChosenColor;
     m_NumberOfDoors = i_CarDoors;
     m_EnergyType    = o_TypeOfEnergy;
     EnergyRatio     = o_TypeOfEnergy.CalculateRatio();
 }
コード例 #8
0
        internal Motorcycle(string i_m_ModelName, string i_LicenseNumber,
                            List <Wheels> i_ListOfWheels, EnergyType i_EnergyType,
                            eLicenseType i_LicenseType, int i_EngineVolume)

            : base(i_m_ModelName, i_LicenseNumber, i_ListOfWheels, i_EnergyType)
        {
            this.r_LicenseType  = i_LicenseType;
            this.r_EngineVolume = i_EngineVolume;
        }
コード例 #9
0
 public Vehicle(string i_ModelName, string i_LicenseNumber, List <Wheels> i_ListOfWheels, EnergyType i_EnergyType)
 {
     this.m_EnergyTpye           = i_EnergyType;
     this.r_LicenseNumber        = i_LicenseNumber;
     this.r_ModelName            = i_ModelName;
     this.r_Wheels               = i_ListOfWheels;
     this.m_EnergyPercentageLeft =
         CalculateEnergyPercentageLeft(m_EnergyTpye.m_CurrentAmountOfEnergy, m_EnergyTpye.r_MaxAmountOfEnergy);
 }
コード例 #10
0
 public static void ValidateElectriclType(EnergyType i_Energy)
 {
     if (i_Energy == EnergyType.Electric)
     {
     }
     else
     {
         throw new ArgumentException();
     }
 }
コード例 #11
0
ファイル: Garage.cs プロジェクト: mirzviz/GarageProject
        public void fuelVehicle(string i_LicencePlate, EnergyType i_FuelType, float i_AddedFuel)
        {
            VehicleInGarage vehicleInGarage = find(i_LicencePlate);

            if (vehicleInGarage == null)
            {
                throw new Exception("Can't fuel! The vehicle's license plate is not found");
            }

            vehicleInGarage.Vehicle.FillTank(i_AddedFuel, i_FuelType);
        }
コード例 #12
0
 public override void EnergySetup(EnergyType i_SourceOfEnergy)
 {
     if (i_SourceOfEnergy is Fuel)
     {
         i_SourceOfEnergy.MaxEnergyCapacity     = (float)Fuel.eMaxFuelCapacity.Truck;
         i_SourceOfEnergy.CurrentEnergyCapacity = (float)Fuel.eMaxFuelCapacity.Truck;
         ((Fuel)i_SourceOfEnergy).FuelType      = Fuel.eFuelType.Soler;
     }
     else
     {
         throw new FormatException("A truck energy type should be only fuel!");
     }
 }
コード例 #13
0
ファイル: Vehicle.cs プロジェクト: itayko2/csharp_2019
        public override string ToString()
        {
            string vehicleInfo = string.Format(
                "Owner's name: {1}{0}Owner's phone: {2}{0}Model: {3}{0}Registration Plate: {4}{0}Number Of Wheels: {5}{0}",
                Environment.NewLine,
                m_OwnersName,
                m_OwnersPhone,
                r_Model,
                r_RegistrationPlate,
                m_NumberOfWheels);

            return(vehicleInfo + m_Wheels[0].ToString() + EnergyType.ToString());
        }
コード例 #14
0
ファイル: Car.cs プロジェクト: naorpa/GrageProject
 public override void EnergySetup(EnergyType i_SourceOfEnergy)
 {
     if (i_SourceOfEnergy is Fuel)
     {
         i_SourceOfEnergy.MaxEnergyCapacity     = (float)Fuel.eMaxFuelCapacity.Car;
         i_SourceOfEnergy.CurrentEnergyCapacity = (float)Fuel.eMaxFuelCapacity.Car;
         ((Fuel)i_SourceOfEnergy).FuelType      = Fuel.eFuelType.Octan96;
     }
     else
     {
         i_SourceOfEnergy.MaxEnergyCapacity     = k_MaxElectricCapacity;
         i_SourceOfEnergy.CurrentEnergyCapacity = k_MaxElectricCapacity;
     }
 }
コード例 #15
0
        public void FillTank(float i_EnergyToAdd, EnergyType i_FuelType)
        {
            if (r_EnergyType != i_FuelType)
            {
                throw new ArgumentException();
            }

            if (i_EnergyToAdd < 0 || m_CurrentCapacity + i_EnergyToAdd > r_MaxCapacity)
            {
                throw new ValueOutOfRangeException(0, r_MaxCapacity - m_CurrentCapacity);
            }

            m_CurrentCapacity += i_EnergyToAdd;
        }
コード例 #16
0
        void CheckAndCreateEngineType(ENumType.eEnergytype i_EngineType, ENumType.eFuelType i_FuelType)
        {
            switch (i_EngineType)
            {
            case ENumType.eEnergytype.Gasoline:
            {
                m_MyEngine = new GasolineEngine(m_EnergyPercentage, r_MaxEnergyCapacity, i_FuelType);
                break;
            }

            case ENumType.eEnergytype.Elecrtic:
            {
                m_MyEngine = new ElectricEngine(m_EnergyPercentage, r_MaxEnergyCapacity);
                break;
            }
            }
        }
コード例 #17
0
        public static Vehicle CreateNewVehicle(
            Vehicle.eVehicleType i_VehicleType,
            string i_Model,
            string i_LicenseNumber,
            EnergyType i_SourceOfEnergy,
            Wheel i_Wheel)
        {
            Vehicle newVehicle = null;

            if (i_VehicleType == Vehicle.eVehicleType.ElectricCar || i_VehicleType == Vehicle.eVehicleType.FuelCar)
            {
                newVehicle = new Car(i_Model, i_LicenseNumber, i_SourceOfEnergy, i_Wheel);
            }
            else if (i_VehicleType == Vehicle.eVehicleType.Truck)
            {
                newVehicle = new Truck(i_Model, i_LicenseNumber, i_SourceOfEnergy, i_Wheel);
            }
            else
            {
                newVehicle = new Motorcycle(i_Model, i_LicenseNumber, i_SourceOfEnergy, i_Wheel);
            }

            return(newVehicle);
        }
コード例 #18
0
ファイル: Vehicle.cs プロジェクト: Dan-Hagever/Garage-Manager
 protected void asssaignEnergySourceToElectric(ref VehicleEnergy io_Energy, float i_CurrentAmount, float i_MaxAmount, EnergyType i_Electric)
 {
     ElectricEnergy.ValidateElectriclType(i_Electric);
     io_Energy           = new ElectricEnergy(i_CurrentAmount, i_MaxAmount);
     PercentOfEnergyLeft = percentOfEnergyLeftCalculation(i_CurrentAmount, i_MaxAmount);
 }
コード例 #19
0
ファイル: Vehicle.cs プロジェクト: Dan-Hagever/Garage-Manager
 protected void asssaignEnergySourceToFuel(ref VehicleEnergy io_Energy, eFuelType i_FuelType, float i_CurrentAmount, float i_MaxAmount, EnergyType i_Fuel)
 {
     FuelEnergy.ValidateFuelType(i_Fuel);
     io_Energy           = new FuelEnergy(i_FuelType, i_CurrentAmount, i_MaxAmount);
     PercentOfEnergyLeft = percentOfEnergyLeftCalculation(i_CurrentAmount, i_MaxAmount);
 }
コード例 #20
0
ファイル: Vehicle.cs プロジェクト: mirzviz/GarageProject
 public void FillTank(float i_EnergyToAdd, EnergyType i_FuelType)
 {
     m_Tank.FillTank(i_EnergyToAdd, i_FuelType);
 }
コード例 #21
0
ファイル: Vehicle.cs プロジェクト: naorpa/GrageProject
 public abstract void EnergySetup(EnergyType i_SourceOfEnergy);
コード例 #22
0
 public Tank(EnergyType i_FuelType, float i_MaxCapacity)
 {
     r_EnergyType  = i_FuelType;
     r_MaxCapacity = i_MaxCapacity;
 }
コード例 #23
0
ファイル: Car.cs プロジェクト: naorpa/GrageProject
 public Car(string i_Model, string i_LicenseNumber, EnergyType i_SourceOfEnergy, Wheel i_Wheel)
     : base(i_Model, i_LicenseNumber, i_SourceOfEnergy)
 {
     EnergySetup(i_SourceOfEnergy);
     AddWheels(i_Wheel, k_NumOfWheels, Wheel.eMaxAirPressure.Car);
 }