private void btnSimulateTemperature_Click(object sender, EventArgs e) { try { Machine m = mc.GetMachine(tbMachineName.Text); if (m != null) { m.SetTemperature(Convert.ToInt32(tbTemp.Text)); } else { MessageBox.Show("We do not have a machine with this name"); } } catch (FormatException) { MessageBox.Show("Please fill in a number for temperature"); } }