コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
 public void ShowWarning(Motorbike m, int extraInfo)
 {
     this.lblWarning.Text = "Slow down! " +
                            extraInfo.ToString() +
                            " km/h over the limit!!!";
 }
コード例 #6
0
 public void ShowCurrentSpeed(Motorbike m, int extraInfo)
 {
     this.lblCurrentSpeed.Text = "speed: " + m.Speed.ToString();
     this.lblWarning.Visible   = (m.Speed > m.MaxSpeed);
 }
コード例 #7
0
 public FormDisplayOnMotorbike(Motorbike m)
 {
     InitializeComponent();
     this.lblNameOfDriver.Text = m.NameOfDriver;
     this.Visible = true;
 }
コード例 #8
0
        private void btnChangeSpeed_Click(object sender, EventArgs e)
        {
            Motorbike m = this.yamahaTeam.GetByName("Rossi");

            m.Accelerate(Convert.ToInt32(this.textBox1.Text));
        }