Ejemplo n.º 1
0
        public IEnumerable <string> ExecuteCommand(IEnumerable <string> commands, Person t)
        {
            List <string> toReturn = new List <string>();

            foreach (string command in commands)
            {
                bool commandExecuted = false;
                switch (command)
                {
                case "8":
                    if (_pj.Satisfies(t))
                    {
                        commandExecuted = true;
                        toReturn.Add(_pj.GetItemDescription());
                        RemovePj(t);
                    }

                    break;

                case "1":
                    if (_footware.Satisfies(t))
                    {
                        commandExecuted = true;
                        toReturn.Add(_footware.GetItemDescription());
                        t.Puton(_footware);
                    }

                    break;

                case "2":
                    if (_headwear.Satisfies(t))
                    {
                        commandExecuted = true;
                        toReturn.Add(_headwear.GetItemDescription());
                        t.Puton(_headwear);
                    }

                    break;

                case "3":
                    if (_socks.Satisfies(t))
                    {
                        commandExecuted = true;
                        toReturn.Add(_socks.GetItemDescription());
                        t.Puton(_socks);
                    }

                    break;

                case "4":
                    if (_shirt.Satisfies(t))
                    {
                        commandExecuted = true;
                        toReturn.Add(_shirt.GetItemDescription());
                        t.Puton(_shirt);
                    }

                    break;

                case "5":
                    if (_jacket.Satisfies(t))
                    {
                        commandExecuted = true;
                        toReturn.Add(_jacket.GetItemDescription());
                        t.Puton(_jacket);
                    }

                    break;

                case "6":
                    if (_pants.Satisfies(t))
                    {
                        commandExecuted = true;
                        toReturn.Add(_pants.GetItemDescription());
                        t.Puton(_pants);
                    }

                    break;

                case "7":
                    if (_leaveTheHouse.Satisfies(t))
                    {
                        commandExecuted = true;
                        toReturn.Add(_leaveTheHouse.GetItemDescription());
                        t.Puton(_leaveTheHouse);
                    }

                    break;
                }

                if (!commandExecuted)
                {
                    toReturn.Add("fail");
                    break;
                }
            }

            return(toReturn);
        }