Exemplo n.º 1
0
        private void executeCommand(Command command, string parameter)
        {
            /** Note for FP recruiter:
             * Please check the 6th point in document, I've been thinking about how to make
             * this method, contemplations were done. Check why the method is done like it is done.
             **/

            bool wasExecutionSuccessful = commandExecutor.TryExecuting(command, parameter);

            try
            {
                var postExecutionState = arcStateReceiver.GetState();
                updateViewAfterExecuting(postExecutionState);
                reporter.UpdateCurrentReport(postExecutionState, postExecutionEvents, $"{command.ToString()} {parameter}");

                if (postExecutionState.Turn.Equals(25))
                {
                    MessageBox.Show("Experiment has ended");
                }
                else if (postExecutionState.IsTerminated)
                {
                    MessageBox.Show("Experiment is terminated! Look what you've done you...");
                }
                else if (!wasExecutionSuccessful)
                {
                    MessageBox.Show("Execution was unsuccessful - Houston, we have a problem!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Receiving of the arcology state failed: {ex.Message}");
            }
        }
Exemplo n.º 2
0
        public MainView(CommandExecutor commandExecutor, ArcStateReceiver arcStateReceiver, ReportWriter reporter)
        {
            InitializeComponent();

            this.commandExecutor  = commandExecutor;
            this.arcStateReceiver = arcStateReceiver;
            this.reporter         = reporter;

            resetSimulation();
            currentState = arcStateReceiver.GetState();
            updateViewArcState(currentState);
        }