コード例 #1
0
 protected new void AddItem(string[] inputParams)
 {
     Character characterToAcceptIitem = GetCharacterById(inputParams[1]);
     Item itemToAdd;
     switch (inputParams[2].ToLower())
     {
         case "axe":
             itemToAdd = new Axe(inputParams[3]);
             characterToAcceptIitem.AddToInventory(itemToAdd);
             break;
         case "shield":
             itemToAdd = new Shield(inputParams[3]);
             characterToAcceptIitem.AddToInventory(itemToAdd);
             break;
         case "pill":
             itemToAdd = new Pill(inputParams[3]);
             characterToAcceptIitem.AddToInventory(itemToAdd);
             break;
         case "injection":
             itemToAdd = new Injection(inputParams[3]);
             characterToAcceptIitem.AddToInventory(itemToAdd);
             break;
         default:
             break;
     }
 }
コード例 #2
0
        protected new void AddItem(string[] inputParams)
        {
            var characterId = inputParams[1];
            var character = this.characterList.Find(x => x.Id == characterId);

            var itemClass = inputParams[2];
            var itemId = inputParams[3];

            Item item;
            switch (itemClass)
            {
                case "axe":
                    item = new Axe(itemId);
                    break;
                case "shield":
                    item = new Shield(itemId);
                    break;
                case "pill":
                    item = new Pill(itemId);
                    break;
                case "injection":
                default:
                    item = new Injection(itemId);
                    break;
            }

            character.AddToInventory(item);
        }
コード例 #3
0
ファイル: Engine.cs プロジェクト: petdakov/SoftUni-Homeworks
        protected void AddItem(string[] inputParams)
        {
            string nameOfCharacter = inputParams[1];
            string typeOfItem = inputParams[2];
            string nameOfItem = inputParams[3];

            switch (typeOfItem)
            {
                case "axe":
                    Item axe = new Axe(nameOfItem);
                    characterList.Find(character => character.Id == nameOfCharacter).AddToInventory(axe);
                    break;
                case "injection":
                    Bonus injection = new Injection(nameOfItem);
                    characterList.Find(character => character.Id == nameOfCharacter).AddToInventory(injection);
                    break;
                case "pill":
                    Bonus pill = new Pill(nameOfItem);
                    characterList.Find(character => character.Id == nameOfCharacter).AddToInventory(pill);
                    break;
                case "shield":
                    Item shield = new Shield(nameOfItem);
                    characterList.Find(character => character.Id == nameOfCharacter).AddToInventory(shield);
                    break;
                default:
                    throw new GameException("No such item exists");
            }
        }
コード例 #4
0
        private 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 "pill":
                    item = new Pill(inputParams[3]);
                    break;
                case "injection":
                    item = new Injection(inputParams[3]);
                    break;
            }

            var target = base.GetCharacterById(inputParams[1]);

            target.AddToInventory(item);
        }
コード例 #5
0
ファイル: CustomEngine.cs プロジェクト: zlatkovtv/SoftUni_OOP
 protected new void AddItem(string[] inputParams)
 {
     Character targetCharacter = GetCharacterById(inputParams[1]);
     Item item;
     switch (inputParams[2].ToLower())
     {
         case "axe":
             item = new Axe(inputParams[3]);
             targetCharacter.AddToInventory(item);
             break;
         case "shield":
             item = new Axe(inputParams[3]);
             targetCharacter.AddToInventory(item);
             break;
         case "pill":
             item = new Axe(inputParams[3]);
             targetCharacter.AddToInventory(item);
             break;
         case "injection":
             item = new Axe(inputParams[3]);
             targetCharacter.AddToInventory(item);
             break;
     }
 }
コード例 #6
0
ファイル: NewEngine.cs プロジェクト: TzvetanIG/OOP
        private new void AddItem(string[] inputParams)
        {
            Item item;
            switch (inputParams[2].ToLower())
            {
                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:
                    throw new ApplicationException("No such kind of item.");
            }

            var character = this.characterList.First(c => c.Id == inputParams[1]);
            character.AddToInventory(item);
        }