Пример #1
0
 public Car()
 {
     fuelTank        = new FuelTank(20);
     engine          = new Engine(fuelTank);
     fuelTankDisplay = new FuelTankDisplay(fuelTank);
     engine.Stop();
 }
Пример #2
0
 public Car(double fillLevel)
 {
     fuelTank        = new FuelTank(fillLevel);
     engine          = new Engine(fuelTank);
     fuelTankDisplay = new FuelTankDisplay(fuelTank);
     engine.Stop();
 }
Пример #3
0
        private void BuildCar(double fuelLevel = 20, int maxAcceleration = 10)
        {
            if (maxAcceleration > 20)
            {
                maxAcceleration = 20;
            }
            else if (maxAcceleration < 5)
            {
                maxAcceleration = 5;
            }

            fuelTank        = new FuelTank();
            fuelTankDisplay = new FuelTankDisplay(fuelTank);
            engine          = new Engine(fuelTank);

            if (fuelTank is Subject && fuelTankDisplay is Observer)
            {
                ((Subject)fuelTank).Attach((Observer)fuelTankDisplay);
            }

            if (fuelTank is Subject && engine is Observer)
            {
                ((Subject)fuelTank).Attach((Observer)engine);
            }

            fuelTank.Refuel(fuelLevel);

            drivingProcessor          = new DrivingProcessor(maxAcceleration);
            drivingInformationDisplay = new DrivingInformationDisplay(drivingProcessor);

            if (drivingProcessor is Subject && drivingInformationDisplay is Observer)
            {
                ((Subject)drivingProcessor).Attach((Observer)drivingInformationDisplay);
            }
        }
Пример #4
0
 public Car(double fuelLevel, int maxAcceleration)     // car #2
 {
     fuelTank                  = new FuelTank(fuelLevel);
     fuelTankDisplay           = new FuelTankDisplay(fuelTank);
     drivingProcessor          = new DrivingProcessor(maxAcceleration);
     drivingInformationDisplay = new DrivingInformationDisplay(drivingProcessor);
     engine = new Engine(fuelTank);
 }
Пример #5
0
 public Car(double fuelLevel)
 {
     fuelTank                  = new FuelTank(fuelLevel);
     fuelTankDisplay           = new FuelTankDisplay(fuelTank);
     engine                    = new Engine(fuelTank);
     drivingProcessor          = new DrivingProcessor();
     drivingInformationDisplay = new DrivingInformationDisplay(drivingProcessor);
 }
Пример #6
0
        public IOnBoardComputerDisplay onBoardComputerDisplay; // car #3



        public Car(double fuelLevel = 20, int maxAcceleration = 10) // car #2
        {
            fuelTank                  = new FuelTank(fuelLevel);
            engine                    = new Engine(fuelTank);
            fuelTankDisplay           = new FuelTankDisplay(fuelTank);
            drivingProcessor          = new DrivingProcessor(engine, maxAcceleration, fuelTank);
            drivingInformationDisplay = new DrivingInformationDisplay(drivingProcessor);
            onBoardComputer           = new OnBoardComputer(drivingProcessor);
            onBoardComputerDisplay    = new OnBoardComputerDisplay(onBoardComputer);
        }
Пример #7
0
 public Car(double fuelLevel)
 {
     fuelTank                  = new FuelTank(fuelLevel);
     engine                    = new Engine(fuelTank);
     fuelTankDisplay           = new FuelTankDisplay(fuelTank);
     drivingProcessor          = new DrivingProcessor();
     drivingInformationDisplay = new DrivingInformationDisplay(drivingProcessor);
     onBoardComputer           = new OnBoardComputer(drivingProcessor, fuelTank);
     onBoardComputerDisplay    = new OnBoardComputerDisplay(onBoardComputer);
 }
Пример #8
0
 public Car(double fuelLevel, int maxAcceleration)
 {
     fuelLevel                 = Math.Max(Math.Min(fuelLevel, 60), 0);
     fuelTank                  = new FuelTank(fuelLevel);
     engine                    = new Engine(fuelTank);
     fuelTankDisplay           = new FuelTankDisplay(fuelTank);
     drivingProcessor          = new DrivingProcessor(engine, maxAcceleration);
     onBoardComputer           = new OnBoardComputer(drivingProcessor, fuelTank);
     drivingInformationDisplay = new DrivingInformationDisplay(drivingProcessor);
     onBoardComputerDisplay    = new OnBoardComputerDisplay(onBoardComputer);
 }
Пример #9
0
 public Car(double fuelLevel = 20)
 {
     engine   = new Engine();
     fuelTank = new FuelTank()
     {
         FillLevel = fuelLevel, IsOnReserve = fuelLevel < 5, IsComplete = fuelLevel == 60
     };
     fuelTankDisplay = new FuelTankDisplay()
     {
         FillLevel = fuelTank.FillLevel, IsOnReserve = fuelTank.IsOnReserve, IsComplete = fuelTank.IsComplete
     };
 }
Пример #10
0
 public Car(double fuelLevel, int maxAcceleration) // car #2
 {
     Console.WriteLine($"New Car. fuelLevel: {fuelLevel}, maxAcceleration: {maxAcceleration}");
     fuelTank                  = new FuelTank(fuelLevel);
     drivingProcessor          = new DrivingProcessor();
     engine                    = new Engine(fuelTank, drivingProcessor);
     fuelTankDisplay           = new FuelTankDisplay(fuelTank);
     drivingInformationDisplay = new DrivingInformationDisplay(drivingProcessor);
     _maxAcceleration          = Math.Clamp(maxAcceleration, MIN_ACCELERATION, MAX_ACCELERATION);
     onBoardComputer           = new OnBoardComputer(drivingProcessor, fuelTank);
     onBoardComputerDisplay    = new OnBoardComputerDisplay(onBoardComputer);
 }
Пример #11
0
    public Car(double fuelLevel)
    {
        fuelTank        = new FuelTank();
        engine          = new Engine(fuelTank);
        fuelTankDisplay = new FuelTankDisplay(fuelTank);

        if (fuelLevel >= 60)
        {
            this.fuelTank.Refuel(60);
        }
        else
        {
            fuelTank.Refuel(fuelLevel);
        }
        engine.Stop();
    }
Пример #12
0
        public Car(double fuelLevel = 20)
        {
            fuelTank        = new FuelTank();
            fuelTankDisplay = new FuelTankDisplay(fuelTank);
            engine          = new Engine(fuelTank);

            if (fuelTank is Subject && fuelTankDisplay is Observer)
            {
                ((Subject)fuelTank).Attach((Observer)fuelTankDisplay);
            }

            if (fuelTank is Subject && engine is Observer)
            {
                ((Subject)fuelTank).Attach((Observer)engine);
            }

            fuelTank.Refuel(fuelLevel);
        }
Пример #13
0
        public Car(double fuelLevel, int maxAcceleration)
        {
            engine                    = new Engine();
            fuelTankDisplay           = new FuelTankDisplay();
            fuelTank                  = new FuelTank(fuelLevel);
            drivingInformationDisplay = new DrivingInformationDisplay();
            drivingProcessor          = new DrivingProcessor(maxAcceleration);
            onBoardComputer           = new OnBoardComputer();
            onBoardComputerDisplay    = new OnBoardComputerDisplay();

            ((Engine)engine).OnEngineConsume += ((FuelTank)fuelTank).HandleConsumeEvent;
            ((OnBoardComputer)onBoardComputer).OnBoardComputerData += ((OnBoardComputerDisplay)onBoardComputerDisplay).ComputerDataHandler;
            ((FuelTank)fuelTank).OnFuelTankChange += ((FuelTankDisplay)fuelTankDisplay).FillLevelStateHandler;
            ((FuelTank)fuelTank).OnFuelTankChange += ((Engine)engine).FuelTankHandler;
            ((FuelTank)fuelTank).OnFuelTankChange += ((OnBoardComputer)onBoardComputer).FuelTankHandler;
            ((DrivingProcessor)drivingProcessor).OnDrivingProcessorChange += ((OnBoardComputer)onBoardComputer).DrivingProcessorHandler;
            ((DrivingProcessor)drivingProcessor).OnDrivingProcessorChange += ((DrivingInformationDisplay)drivingInformationDisplay).ActualSpeedHandler;
            ((DrivingProcessor)drivingProcessor).OnDrivingProcessorChange += ((Engine)engine).DrivingProcessorHandler;
            ((OnBoardComputerDisplay)onBoardComputerDisplay).OnTripReset  += ((OnBoardComputer)onBoardComputer).TripResetHandler;
            ((OnBoardComputerDisplay)onBoardComputerDisplay).OnTotalReset += ((OnBoardComputer)onBoardComputer).TotalResetHandler;
            ((FuelTank)fuelTank).SendState();
        }
Пример #14
0
 public Car()
 {
     engine          = new Engine();
     fuelTank        = new FuelTank();
     fuelTankDisplay = new FuelTankDisplay();
 }
Пример #15
0
 public Car(double fuelLevel = 20)
 {
     fuelTank        = new FuelTank(fuelLevel);
     engine          = new Engine(fuelTank as FuelTank);
     fuelTankDisplay = new FuelTankDisplay(fuelTank as FuelTank);
 }
Пример #16
0
 private void SetupCar(double fuellevel)
 {
     engine          = new Engine();
     fuelTank        = new FuelTank(fuellevel);
     fuelTankDisplay = new FuelTankDisplay(fuelTank);
 }