示例#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";
 }
示例#2
0
文件: Form1.cs 项目: jdwoo090/Car
        private void checkFuelButton_Click(object sender, EventArgs e)
        {
            string answer = car.gasLeft().ToString();

            MessageBox.Show("The car has " + answer + " gallons of fuel left.", "Fuel", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }