Exemplo n.º 1
0
        static async System.Threading.Tasks.Task Main(string[] args)
        {
            //Setting up employees
            Dietitian       theDietitian       = new Dietitian("Mrs Lind", Employee.Positions.Dietitian);
            PersonalTrainer thePersonalTrainer = new PersonalTrainer("Arnold Schwarzenegger", Employee.Positions.PersonalTrainer);
            //Setting up clinic
            NutritionClinic theClinic = new NutritionClinic("Mayonaise Foundation", theDietitian, thePersonalTrainer);

            var input = new TextInput();
            var gui   = new ConsoleGUI()
            {
                Input = input
            };
            var sim = new MySimulation(input, theClinic);
            await gui.Start(sim);
        }
        public override void HandleInput(string command, MySimulation sim)
        {
            if (MakeSmoothieState == 0)
            {
                choice1 = command;
                MakeSmoothieState++;
                sim.messageBoard.Log("Pick another ingredient");
            }
            else if (MakeSmoothieState == 1)
            {
                choice2 = command;

                if (int.TryParse(choice1, out int index1))
                {
                    if (int.TryParse(choice2, out int index2))
                    {
                        try
                        {
                            sim.messageBoard.Log(sim.TheClinic.CurrentClient.DrinkSmoothie(index1, index2));
                        }
                        catch (ArgumentOutOfRangeException)
                        {
                            GiveInvalidSmoothieChoicesMessageAndThrowOutClientFromSmoothieBar(sim);
                        }
                        finally
                        {
                            MakeSmoothieState = 0;
                            sim.simState      = new StandardState("MESSAGE BOARD");
                        }
                    }
                    else
                    {
                        GiveInvalidSmoothieChoicesMessageAndThrowOutClientFromSmoothieBar(sim);
                        MakeSmoothieState = 0;
                    }
                }
                else
                {
                    GiveInvalidSmoothieChoicesMessageAndThrowOutClientFromSmoothieBar(sim);
                    MakeSmoothieState = 0;
                }
            }
        }
 private void GiveInvalidSmoothieChoicesMessageAndThrowOutClientFromSmoothieBar(MySimulation sim)
 {
     sim.messageBoard.Log("Something was wrong with your choices... Did you pick something strange?!");
     sim.messageBoard.Log("Comeback later and try again");
     sim.simState = new StandardState("MESSAGE BOARD");
 }
Exemplo n.º 4
0
 public string Execute(MySimulation sim)
 {
     return($"{sim.TheClinic.CurrentClient.Name} trained! {sim.TheClinic.CurrentClient.Train()}");
 }
Exemplo n.º 5
0
 public abstract void HandleInput(string input, MySimulation sim);