예제 #1
0
        public GearBox(GearBox copy, DieselEngine de)
        {
            mstsParams   = new MSTSGearBoxParams(copy.mstsParams);
            DieselEngine = de;

            if (mstsParams != null)
            {
                if ((!mstsParams.IsInitialized) && (mstsParams.AtLeastOneParamFound))
                {
                    Trace.TraceWarning("Some of the gearbox parameters are missing! Default physics will be used.");
                }
                for (int i = 0; i < mstsParams.GearBoxNumberOfGears; i++)
                {
                    Gears.Add(new Gear(this));
                    Gears[i].BackLoadForceN      = mstsParams.GearBoxBackLoadForceN;
                    Gears[i].CoastingForceN      = mstsParams.GearBoxCoastingForceN;
                    Gears[i].DownGearProportion  = mstsParams.GearBoxDownGearProportion;
                    Gears[i].IsDirectDriveGear   = (mstsParams.GearBoxDirectDriveGear == mstsParams.GearBoxNumberOfGears);
                    Gears[i].MaxSpeedMpS         = mstsParams.GearBoxMaxSpeedForGearsMpS[i];
                    Gears[i].MaxTractiveForceN   = mstsParams.GearBoxMaxTractiveForceForGearsN[i];
                    Gears[i].OverspeedPercentage = mstsParams.GearBoxOverspeedPercentageForFailure;
                    Gears[i].UpGearProportion    = mstsParams.GearBoxUpGearProportion;
                    Gears[i].Ratio = mstsParams.GearBoxMaxSpeedForGearsMpS[i] / DieselEngine.MaxRPM;
                }
                GearBoxOperation         = mstsParams.GearBoxOperation;
                OriginalGearBoxOperation = mstsParams.GearBoxOperation;
            }
        }
예제 #2
0
        public override Car GetCar()
        {
            Engine e = null;

            switch (configurations.Engine.EngineType)
            {
            case EEngine.Diesel:
                e = new DieselEngine();
                break;

            case EEngine.Petrol:
                e = new PetrolEngine();
                break;

            case EEngine.Gas:
                e = new GasEngine();
                break;
            }
            Car newCar = new CustomizedCar(++_iNumberOfCars)
            {
                Engine           = e,
                Model            = configurations.Model,
                Base             = new Base(),
                Breaks           = new Breaks(),
                Electronics      = new Electronics(),
                ExhaustingSystem = new ExhaustingSystem(),
            };
            CarEnhancer enh = new CarEnhancer();

            enh.Enhance(newCar, configurations.CarType);
            return(newCar);
        }
예제 #3
0
        public static void Main(string[] args)
        {
            Person person = new Person
            {
                FirstName   = "Abc",
                LastName    = "Xyz",
                DateOfBirth = new DateTime(1992, 11, 16)
            };

            Console.WriteLine("Age is {0}", person.GetAge());


            //Static Polymorphism
            DieselEngine dieselEngine = new DieselEngine();

            dieselEngine.Start();

            //Dynamic Polymorphism
            Engine engine = new PetrolEngine();

            engine.Start();

            Exhaustable exhaustable = new Car(engine);

            exhaustable.Exhaust();

            exhaustable = new PowerGenerator();
            exhaustable.Exhaust();
        }
예제 #4
0
파일: GearBox.cs 프로젝트: robwor/openrails
        public GearBox(GearBox copy, DieselEngine de)
        {
            mstsParams   = new MSTSGearBoxParams(copy.mstsParams);
            DieselEngine = de;

            CopyFromMSTSParams(DieselEngine);
        }
예제 #5
0
        public Car CreateCar()
        {
            int      carCost = 0;
            string   model;
            bool     result          = false;
            int      nummberOfBody   = 0;
            int      nummberOfEngine = 0;
            ICarBody bodyCar;
            IEngine  engineCar;
            string   enterTheCost   = "Enter the cost of the car";
            string   choseTheBody   = "Choose a car body \r\n 1.Coupe \r\n 2.Hatchback \r\n 3.Minivan ";
            string   choseTheEngine = "Choose a car engine \r\n 1.DieselEngine \r\n 2.ElectricalEngine \r\n 3.GasolineEngine ";

            Console.WriteLine("Enter the name of the car");
            model = Console.ReadLine();
            InputValidation(result, enterTheCost, ref carCost, 0, 9223372036854000000);
            InputValidation(result, choseTheBody, ref nummberOfBody, 1, 3);

            switch (nummberOfBody)
            {
            case 1: bodyCar = new Coupе();;
                break;

            case 2:
                bodyCar = new Hatchback();;
                break;

            case 3:
                bodyCar = new Minivan();;
                break;

            default: bodyCar = null;
                break;
            }

            InputValidation(result, choseTheEngine, ref nummberOfEngine, 1, 3);


            switch (nummberOfEngine)
            {
            case 1:
                engineCar = new DieselEngine();;
                break;

            case 2:
                engineCar = new ElectricalEngine();;
                break;

            case 3:
                engineCar = new GasolineEngine();;
                break;

            default:
                engineCar = null;
                break;
            }
            Console.WriteLine();
            return(new Car(engineCar, bodyCar, carCost, model, IdOfCar));
        }
 public override void BuildCar()
 {
     Brakes       = new DiskBrakes();
     Engine       = new DieselEngine();
     Steering     = new PowerSteering();
     Transmission = new AutomaticTransmission();
     Wheels       = new AlloyWheels();
 }
예제 #7
0
        public void DieselEngine_Set_Get(uint a)
        {
            DieselEngine _suut = new DieselEngine(a);
            MotorBike    _uut  = new MotorBike(_suut);

            Assert.That(_suut.CurThrottle = a, Is.EqualTo(a));
            _uut.RunAtHalfSpeed();
            Assert.That(_suut.CurThrottle, Is.EqualTo(a / 2));
        }
예제 #8
0
파일: Program.cs 프로젝트: nicho1991/SWD
        static void Main(string[] args)
        {
            IEngine   eng1 = new GasEngine(20);
            IEngine   eng2 = new DieselEngine(50);
            Motorbike m    = new Motorbike(eng1);
            Motorbike m2   = new Motorbike(eng2);

            m.RunAtHalfSpeed();
            m2.RunAtHalfSpeed();
        }
예제 #9
0
        public DieselEngine getDieselEngine(string[] items)
        {
            DieselEngine dieselEngine = new DieselEngine();

            dieselEngine.Power        = int.Parse(items[7]);
            dieselEngine.Manufacturer = items[8];
            dieselEngine.DCubes       = int.Parse(items[9]);

            return(dieselEngine);
        }
예제 #10
0
    public static void Main()
    {
        Car    ciaz   = new Car();
        Engine engine = new DieselEngine();

        Console.WriteLine(engine.Start());
        Console.WriteLine(engine.engineType());
        Console.WriteLine(ciaz.Start());
        Console.WriteLine(ciaz.Accelerate());
        Console.WriteLine(engine.Stop());
        Console.WriteLine(ciaz.Stop());
    }
예제 #11
0
        public void CarPriceUpdated_WhenISelectEngineAndGearbox()
        {
            // Given
            Car car = new Limousine();

            // When
            car = new DieselEngine(car);
            car = new AutomaticGearbox(car);

            // Then
            Assert.Equal(114200, car.GetCost());
        }
예제 #12
0
        static void Main(string[] args)
        {
            System.Console.WriteLine("::::::::GasEngine::::::::");
            IEngine myGasEngine = new GasEngine(10);
            MotorBike myGasBike = new MotorBike(myGasEngine);
            System.Console.WriteLine("Run at half speed.");
            myGasBike.RunAtHalfSpeed();

            System.Console.WriteLine("::::::::DieselEngine:::::");
            IEngine myDieEngine = new DieselEngine(20);
            MotorBike myDieselBike = new MotorBike(myDieEngine);
            System.Console.WriteLine("Run at half speed.");
            myDieselBike.RunAtHalfSpeed();
        }
예제 #13
0
        static void Main(string[] args)
        {
            // ************************************** //
            // *** Gas engine and gas-driven bike *** //
            // ************************************** //
            var myGasEngine    = new GasEngine(100);
            var myGasMotorBike = new MotorBike(myGasEngine);
            var thr            = myGasEngine.CurThrottle;

            Console.WriteLine($"My gas throttle when idling is: {thr}.");
            thr = myGasEngine.MaxThrottle;
            Console.WriteLine($"My gas throttle at full speed is: {thr}");
            myGasMotorBike.RunAtHalfSpeed();
            thr = myGasEngine.CurThrottle;
            Console.WriteLine($"My gas throttle at half speed is: {thr}");

            // ******************************************** //
            // *** Diesel engine and diesel-driven bike *** //
            // ******************************************** //
            var myDieselEngine    = new DieselEngine(120);
            var myDieselMotorBike = new MotorBike(myDieselEngine);
            // Diesel-bike outputs:
            var thr2 = myDieselEngine.CurThrottle;

            Console.WriteLine($"My diesel throttle when idling is: {thr2}");
            thr2 = myDieselEngine.MaxThrottle;
            Console.WriteLine($"My diesel throttle at full speed is: {thr2}");
            myDieselMotorBike.RunAtHalfSpeed();
            thr2 = myDieselEngine.CurThrottle;
            Console.WriteLine($"My diesel throttle at half speed is: {thr2}");

            // ************************************************ //
            // *** Electric engine and electric-driven bike *** //
            // ************************************************ //
            var myElectricEngine    = new ElectricEngine(168);
            var myElectricMotorBike = new MotorBike(myElectricEngine);
            // Electric-bike outputs:
            var thr3 = myElectricEngine.CurThrottle;

            Console.WriteLine($"My electric throttle when idling is: {thr3}");
            thr3 = myElectricEngine.MaxThrottle;
            Console.WriteLine($"My electric throttle at full speed is: {thr3}");
            myElectricMotorBike.RunAtHalfSpeed();
            thr3 = myElectricEngine.CurThrottle;
            Console.WriteLine($"My electric throttle at half speed is: {thr3}");

            Console.ReadLine();
        }
예제 #14
0
        static void Main(string[] args)
        {
            System.Console.WriteLine("::::::::GasEngine::::::::");
            IEngine   myGasEngine = new GasEngine(10);
            MotorBike myGasBike   = new MotorBike(myGasEngine);

            System.Console.WriteLine("Run at half speed.");
            myGasBike.RunAtHalfSpeed();

            System.Console.WriteLine("::::::::DieselEngine:::::");
            IEngine   myDieEngine  = new DieselEngine(20);
            MotorBike myDieselBike = new MotorBike(myDieEngine);

            System.Console.WriteLine("Run at half speed.");
            myDieselBike.RunAtHalfSpeed();
        }
예제 #15
0
 public GearBox(DieselEngine de)
 {
     DieselEngine = de;
     Locomotive   = de.Locomotive;
 }
예제 #16
0
 private object OnDieselEngineToggle(DieselEngine engine, BasePlayer player)
 {
     return(Interface.Oxide.CallDeprecatedHook("OnDieselEngineToggle", "OnDieselEngineToggle(DieselEngine engine, BasePlayer player)",
                                               new DateTime(2022, 12, 31), player, engine));
 }
    public override DieselEngine VisitDieselEngine(DieselEngine engine)
    {
        VisitEngine(engine);

        return(engine);
    }
 public virtual DieselEngine VisitDieselEngine(DieselEngine engine) => engine;
예제 #19
0
파일: GearBox.cs 프로젝트: robwor/openrails
 public void UseLocoGearBox(DieselEngine dieselEngine)
 {
     DieselEngine = dieselEngine;
 }
 public DieselCar()
 {
     engine = new DieselEngine();
 }
예제 #21
0
 protected override void EngineOn()
 {
     DieselEngine.StartFuelPump();
     DieselEngine.Run();
 }