Exemplo n.º 1
0
        public static void showRoom(HashTable ht, Player p)
        {
            string choice;

            Console.WriteLine("WELCOME TO THE SHOWROOM!!!!");
            ht.printTable();
            Console.WriteLine(" You have " + p.money + " money.");
            Console.WriteLine("Please select a weapon to buy('end' to quit):");
            choice = Console.ReadLine();
            while (choice.CompareTo("end") != 0 && !p.inventoryFull())
            {
                Weapon w = ht.get(choice);
                if (w != null)
                {
                    if (w.cost > p.money)
                    {
                        Console.WriteLine("Insufficient funds to buy " + w.weaponName);
                    }
                    else
                    {
                        p.buy(w);
                        p.withdraw(w.cost);
                    }
                }
                else
                {
                    Console.WriteLine(" ** " + choice + " not found!! **");
                }
                Console.WriteLine("Please select another weapon to buy('end' to quit):");
                choice = Console.ReadLine();
            }
            Console.WriteLine();
        }
Exemplo n.º 2
0
        public static void showRoom(HashTable ht, Player p)
        {
            string choice;

            Console.WriteLine("WELCOME TO THE SHOWROOM!!!!");
            ht.printTable();
            Console.WriteLine(" You have " + p.money + " money.");
            Console.WriteLine("Please select a weapon to buy('end' to quit):");
            Console.WriteLine("Enter 'Delete' in order to Delete an Item from the Showroom:");
            Console.WriteLine("Enter 'Add' in order to add an Item to the Shop:");
            choice = Console.ReadLine();
            while (choice.CompareTo("end") != 0 && !p.inventoryFull())
            {
                Weapon w = ht.get(choice);
                if (w != null)
                {
                    if (w.cost > p.money)
                    {
                        Console.WriteLine("Insufficient funds to buy " + w.weaponName);
                    }
                    else
                    {
                        p.buy(w);
                        p.withdraw(w.cost);
                    }
                }
                if (choice == "Delete")
                {
                    Console.WriteLine("Please select a weapon to delete:");
                    string weaponName = Console.ReadLine();
                    ht.Delete(weaponName);
                    Console.Clear();
                    showRoom(ht, p);
                }
                if (choice == "Add")
                {
                    addWeapons(ht);
                    showRoom(ht, p);
                }
                else
                {
                    Console.WriteLine(" ** " + choice + " not found!! **");
                }
                Console.WriteLine("Please select another weapon to buy('end' to quit):");

                choice = Console.ReadLine();
            }
            Console.WriteLine();
        }