private void button1_Click(object sender, EventArgs e) { if (CN == true) { m_c.setName(textBox6.Text); } if (TC == true) { m_c.setTankCapacity(int.Parse(textBox1.Text)); } if (Speed == true) { m_c.setSpeed(int.Parse(textBox2.Text)); } if (Gas) { if (int.Parse(textBox1.Text) >= int.Parse(textBox3.Text)) { m_c.fill(int.Parse(textBox3.Text)); } else { MessageBox.Show("That is over the tank capacity, so we have just filled it up to the max level!"); m_c.fill(int.Parse(textBox1.Text)); } } if (MPG) { m_c.setMPG(int.Parse(textBox4.Text)); } if (Fuel) { //Discontinued } Close(); }
private void fillB_Click(object sender, EventArgs e) { try { m_car.fill(int.Parse(galTB.Text)); } catch (FormatException) { MessageBox.Show("Invalid Parameters."); } UpdateForm(); }
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(); }