public static void deleteWeapon(BST shop) { Console.Clear(); Console.WriteLine("=====Delete weapon from shop====="); shop.inOrder(); Console.WriteLine("Enter the weapon you wish to delete"); string choice = Console.ReadLine(); if (shop.search(choice) != null) { shop.delete(choice); Console.WriteLine(choice + " deleted, Press any key to continue"); } else { Console.WriteLine(" ** " + choice + " not found!! Press any key to continue**"); } Console.ReadKey(); }
public static void showRoom(BST shop, Player p) { Console.Clear(); string choice; Console.WriteLine("WELCOME TO THE SHOWROOM!!!!"); shop.inOrder(); 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) { if (!p.inventoryFull()) { if (shop.search(choice) != null) { Weapon w = shop.search(choice).w; if (w.cost > p.money) { Console.WriteLine("Insufficient funds to buy " + w.weaponName); } else if (p.bp.maxWeight < (p.bp.presentWeight + w.weight)) { Console.WriteLine("Buying this items causes the backpack to exceed max weight! Item not bought.\nPress any key to continue."); Console.ReadKey(); } 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(); * } * /*Weapon w = shop.search(choice).w; * if (w != null) * { * if (w.cost > p.money) * { * Console.WriteLine("Insufficient funds to buy " + w.weaponName); * } * else if(p.bp.maxWeight < (p.bp.presentWeight + w.weight)) * { * Console.WriteLine("Buying this items causes the backpack to exceed max weight! Item not bought.\nPress any key to continue."); * Console.ReadKey(); * } * 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(); } else { Console.WriteLine("Inventory is full!\nPress any key to continue."); Console.ReadKey(); break; } /* Weapon w = shop.search(choice).w; * 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();*/ } }