private void ShowInformationAboutOverSpeedlimit(Motorbike m, int s) { String holder; holder = "WARNING " + DateTime.Now.ToString() + " " + m.NameOfDriver + " too fast by " + s + " km/h."; this.listBox1.Items.Add(holder); }
private void ShowInformationAboutSpeed(Motorbike m, int s) { String holder; holder = DateTime.Now.ToString() + " " + m.NameOfDriver + " current speed is " + s + " km/h."; this.listBox1.Items.Add(holder); }
private void btnStartTheMotors_Click(object sender, EventArgs e) { // create a display for Valentino Rossi's motorbike // make sure from now on Valentino Rossi's display will show // information about his speed // and about exceeding the speedlimit. Motorbike m = this.yamahaTeam.GetByName("Rossi"); FormDisplayOnMotorbike f = new FormDisplayOnMotorbike(m); // also create a window form to be used in the pits FormForPits ffp = new FormForPits(this.yamahaTeam); m.speedChanged += new Motorbike.SpeedChangedHandler(f.ShowCurrentSpeed); m.speedTooFast += new Motorbike.SpeedChangedHandler(f.ShowWarning); }
private void btnNoLongerNotifiedAboutADriver_Click(object sender, EventArgs e) { Motorbike m = this.racingteam.GetByName(this.textBox1.Text); if (m != null) { //todo m.speedChanged -= new Motorbike.SpeedChangedHandler( this.ShowInformationAboutSpeed); m.speedTooFast -= new Motorbike.SpeedChangedHandler( this.ShowInformationAboutOverSpeedlimit); } }
public void ShowWarning(Motorbike m, int extraInfo) { this.lblWarning.Text = "Slow down! " + extraInfo.ToString() + " km/h over the limit!!!"; }
public void ShowCurrentSpeed(Motorbike m, int extraInfo) { this.lblCurrentSpeed.Text = "speed: " + m.Speed.ToString(); this.lblWarning.Visible = (m.Speed > m.MaxSpeed); }
public FormDisplayOnMotorbike(Motorbike m) { InitializeComponent(); this.lblNameOfDriver.Text = m.NameOfDriver; this.Visible = true; }
private void btnChangeSpeed_Click(object sender, EventArgs e) { Motorbike m = this.yamahaTeam.GetByName("Rossi"); m.Accelerate(Convert.ToInt32(this.textBox1.Text)); }