Exemplo n.º 1
0
        public new void AddItem(string[] inputParams)
        {
            Item item = null;

            switch (inputParams[2])
            {
            case "axe":
                item = new Axe(inputParams[3]);
                break;

            case "shield":
                item = new Shield(inputParams[3]);
                break;

            case "injection":
                item = new Injection(inputParams[3]);
                break;

            case "pill":
                item = new Pill(inputParams[3]);
                break;

            default:
                break;
            }

            this.characterList.First(x => x.Id == inputParams[1]).AddToInventory(item);
        }
Exemplo n.º 2
0
        protected new void AddItem(string[] inputParams)
        {
            Item item;

            switch (inputParams[2])
            {
            case "axe": item = new Axe(inputParams[3]);
                break;

            case "shield": item = new Shield(inputParams[3]);
                break;

            case "injection": item = new Injection(inputParams[3]);
                break;

            case "pill": item = new Injection(inputParams[3]);
                break;

            default: throw new Exception("Sorry, something went wrong :(.");
            }

            var heroe = characterList.Find(character => character.Id == inputParams[1]);

            heroe.AddToInventory(item);
        }
Exemplo n.º 3
0
        protected override void AddItem(string[] inputParams)
        {
            string character = inputParams[1];
            string itemClass = inputParams[2];
            string itemId    = inputParams[3];

            Item item;

            switch (itemClass)
            {
            case "axe":
                Item axe = new Axe(itemId);
                characterList.Find(x => x.Id == character).AddToInventory(axe);
                break;

            case "injection":
                Item injection = new Injection(itemId);
                characterList.Find(x => x.Id == character).AddToInventory(injection);
                break;

            case "pill":
                Item pill = new Pill(itemId);
                characterList.Find(x => x.Id == character).AddToInventory(pill);
                break;

            case "shield":
                Item shield = new Shield(itemId);
                characterList.Find(x => x.Id == character).AddToInventory(shield);
                break;

            default:
                throw new ArgumentException("Item missing", "No such an item exist.");
            }
        }