Beispiel #1
0
 public void UpdateForm()
 {
     carName.Text     = m_car.getName();
     speed.Text       = m_car.getSpeed().ToString();
     mpg.Text         = m_car.getMPG().ToString("N2");
     gas.Text         = m_car.gasLeft().ToString("N2");
     capacity.Text    = m_car.getCapacity().ToString("N2");
     miles.Text       = m_car.getMiles().ToString("N2");
     gasBar.Maximum   = (int)m_car.getCapacity();
     gasBar.Value     = (int)m_car.gasLeft();
     aGauge2.MaxValue = (int)m_car.getCapacity();
     aGauge2.MaxValue = (int)m_car.gasLeft();
     speedBar.Value   = m_car.getSpeed();
     aGauge1.Value    = m_car.getSpeed();
     if (m_car.gasLeft() < 2)
     {
         gasLight.Visible = true;
     }
     else
     {
         gasLight.Visible = false;
     }
     //minTB.Text = "0";
     //galTB.Text = "0";
     //speedTB.Text = "0";
 }
Beispiel #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         m_car = new Car(double.Parse(capTB.Text), double.Parse(mpgTB.Text), nameTB.Text);
         m_car.setSpeed(60);
         m_car.fill((int)m_car.getCapacity());
     }
     catch (FormatException)
     {
         MessageBox.Show("Invalid Parameters. Car cannot be created.");
         return;
     }
     this.Close();
 }