private void runSimulationButton_Click(object sender, EventArgs e) { battleResultTextBox.Clear(); try { ValidateFileInput(fleet1TextBox, "fleet 1"); ValidateFileInput(fleet2TextBox, "fleet 2"); int seed = ValidateSeed(); Random random = new Random(seed); Fleet fleet1 = CreateFleet(random, fleet1TextBox.Text); Fleet fleet2 = CreateFleet(random, fleet2TextBox.Text); SpaceBattle battle = new SpaceBattle(fleet1, fleet2); IBattleObserver observer = new BattleObserverImpl(battleResultTextBox); // add observer battle.Subscribe(observer); battle.CommenceBattle(); battle.ReportBattleResults(); // clean up, remove observer battle.UnSubscribe(observer); } catch (Exception ex) { MessageBox.Show("Program failed with the following error" + Environment.NewLine + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }