public void OnMotoreSpento() { Console.WriteLine("OnMotoreSpento"); MotoreSpento?.Invoke(this, new GiritMotoreEventArgs() { NumeroGiriRAggiunto = this._numerogiri }); }
protected virtual void OnMotoreSpento() { //if (MotoreSpento != null) //{ // MotoreSpento(this, EventArgs.Empty); //} //oppure //MotoreSpento?.Invoke(this, EventArgs.Empty); //oppure MotoreSpento?.Invoke(this, new GiritMotoreEventArgs() { NumeroGiriRAggiunto = this._numerogiri }); }
public void Accellera() { if (this.EngineOn) { this.numeroGiri += 100; if (this.numeroGiri > 500) { /* * if (MotoreFuoriGiri != null) * MotoreFuoriGiri(this, EventArgs.Empty); */ MotoreFuoriGiri?.Invoke(this, EventArgs.Empty); } } else { MotoreSpento?.Invoke(this, EventArgs.Empty); } }
public void Decellera() { if (this.EngineOn) { this.numeroGiri -= 100; if (this.numeroGiri < 100) { this.numeroGiri = 0; this.EngineOn = false; /* * if (MotoreSpento != null) * MotoreSpento(this, EventArgs.Empty); */ MotoreSpento?.Invoke(this, EventArgs.Empty); } } else { MotoreSpento?.Invoke(this, EventArgs.Empty); } }