Ejemplo n.º 1
0
        private static String findItem()
        {
            int    itemNumber = MyConsole.GetInt("Number: ", 1, items.Count);
            String item       = items[itemNumber - 1];

            return(item);
        }
Ejemplo n.º 2
0
        public static List <String> DropItem(List <String> wizardItems)
        {
            int enterNumber = MyConsole.GetInt("Number: ");

            enterNumber--;
            Console.WriteLine(wizardItems[enterNumber] + " was dropped");
            wizardItems.RemoveAt(enterNumber);
            return(wizardItems);
        }
Ejemplo n.º 3
0
        public static List <String> EditItem(List <String> wizardItems)
        {
            int enterNumber = MyConsole.GetInt("Number: ");

            enterNumber--;
            String editItem = MyConsole.GetString("Updated name: ");

            wizardItems[enterNumber] = editItem;
            enterNumber++;
            Console.WriteLine("Item number " + enterNumber + " was updated");
            return(wizardItems);
        }
Ejemplo n.º 4
0
        public static ArrayList EditItem(ArrayList inventory)
        {
            int itemNum   = MyConsole.GetInt("Number: ", 1, 4);
            int selection = itemNum;

            itemNum--;
            String updateItem = MyConsole.GetString("Updated name: ");

            inventory[itemNum] = updateItem;
            Console.WriteLine("Item number " + selection + " was updated.");
            return(inventory);
        }
Ejemplo n.º 5
0
 public static ArrayList DropItem(ArrayList inventory)
 {
     if (inventory.Count != 0)
     {
         try
         {
             int itemNum = MyConsole.GetInt("Number: ", 1, 4);
             itemNum--;
             Console.WriteLine(inventory[itemNum] + " was dropped.");
             inventory.RemoveAt(itemNum);
         } catch (Exception e)
         {
             Console.WriteLine("No item found.");
         }
     }
     else
     {
         Console.WriteLine("Inventory is empty. Please add items.");
     }
     return(inventory);
 }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to the Wizard Inventory App!");


            initializeItems1();

            String command = "";

            while (!command.Equals("Exit"))
            {
                displayMenu();
                command = MyConsole.getString("Command: ");
                switch (command)
                {
                case "Show":
                    // show item
                    for (int i = 0; i < items.Count; i++)
                    {
                        Console.WriteLine(i + 1 + ". " + items[i]);
                    }
                    Console.WriteLine();
                    break;

                case "Grab":
                    // grab item / add item, but max of 4
                    if (items.Count >= 4)
                    {
                        Console.WriteLine("You can't carry anymore items. Please drop one first");
                    }
                    else
                    {
                        String name = MyConsole.getString("Name: ");
                        items.Add(name);
                        Console.WriteLine(name + "was added.");
                    }
                    break;

                case "Edit":
                    // edit item - prompt for item # ( not the index!)

                    String item    = findItem();
                    int    idx     = items.IndexOf(item);
                    String newName = MyConsole.getLine("Updated name: ");
                    items[idx] = newName;
                    Console.WriteLine("Item #" + (idx + 1) + "was updated.");

                    break;

                case "Drop":
                    // drop item
                    int itemNumber = MyConsole.GetInt("Number:", 1, items.Count);
                    item = items[itemNumber - 1];
                    items.Remove(item);
                    Console.WriteLine(item + "was removed.");

                    break;

                case "Exit":
                    // exit
                    break;
                }
            }
            Console.WriteLine("Bye!");
        }