Exemple #1
0
        static void ChooseUserAction(Plant[] plants, User user)
        {
            UserAction action = UserAction.Default;

            while (action != UserAction.Exit)
            {
                view.ShowMenu();
                switch (action = view.GetUserAction())
                {
                case UserAction.Water:
                    Water(ChoosePlant(plants));
                    break;

                case UserAction.Take:
                    TakeFlower(ChoosePlant(plants), user);
                    break;

                case UserAction.Wait:
                    Wait(plants);
                    if (IsEverybodyDead(plants))
                    {
                        action = UserAction.Exit;
                    }
                    break;

                case UserAction.ShowStatus:
                    ShowStatus(plants);
                    break;

                case UserAction.Exit:
                    action = UserAction.Exit;
                    break;

                default:
                    view.Alert(viewText.notCorrectInput);
                    break;
                }
                view.ShowScore(user);
            }
        }