示例#1
0
        public string AddItemToPool(string[] args)
        {
            if (args[0] != "FirePotion" && args[0] != "HealthPotion")
            {
                throw new ArgumentException($"Invalid item \"{args[0]}\"!");
            }

            if (args[0] == "FirePotion")
            {
                Item item = new FirePotion();
                items.Push(item);
                return($"{item.GetType().Name} added to pool.");
            }
            else
            {
                Item item = new HealthPotion();
                items.Push(item);
                return($"{item.GetType().Name} added to pool.");
            }
        }