internal void checkIfItsNeedStopingForGaz(object o, Car car) { DriveCar dc = (DriveCar)o; if (dc.increaseBy >= 5) { car.gazIndicator++; } if (car.gazIndicator >= 3) { car.stopForFillingGaz = true; Console.WriteLine("The car is stopping for gaz"); car.currentSpeed = 0; car.shouldStop = true; } }
static void Main(string[] args) { Car car = new Car(); DriveSpeedManager speedManager = new DriveSpeedManager(); //subscriber DriveCar driveCar = new DriveCar(car); //publisher driveCar._changeEvent += speedManager.checkIfItsNeedStopingForGaz; driveCar._changeEvent += speedManager.showMySpeed; driveCar._changeEvent += speedManager.handleDrivingOverLimit; driveCar._changeEvent += speedManager.stopCar; driveCar._changeEvent += speedManager.sendMessageWhenCarIsStop; driveCar._whenCarNeedGaz += GazManager.carIsStopForGaz; driveCar.startDriving(20); }