/// <summary> /// Construct a default B52WeaponLoader object /// </summary> public B52WeaponLoader() { InitializeComponent(); b52 = new B52(); WeightLabel.Content = b52.CalcWeight(); FuelLabel.Content = b52.Fuel; }
/// <summary> /// Add fuel into the loader /// </summary> private void AddFuel(object sender, RoutedEventArgs e) { // Allow only positive number in the field if (System.Text.RegularExpressions.Regex.IsMatch(FuelTextBox.Text, "[^0-9]")) { MessageBox.Show("Enter only positive number \n"); FuelTextBox.Text = "100000"; } else { int fuelWeight = int.Parse(FuelTextBox.Text); try { b52.AddFuel(fuelWeight); } catch (FuelErrorException ex) { MessageBox.Show(ex.Message); } catch (WeightErrorException ex) { MessageBox.Show(ex.Message); } WeightLabel.Content = b52.CalcWeight(); FuelLabel.Content = b52.Fuel; IsReady(); } }