コード例 #1
0
        public static void addWeapons(HashTable h)
        {
            Console.WriteLine("***********WELCOME TO THE WEAPON ADDING MENU*********");
            string weaponName; int weaponRange; int weaponDamage; double weaponWeight; double weaponCost;

            Console.WriteLine("Please enter the NAME of the Weapon ('end' to quit):");
            weaponName = Console.ReadLine();
            while (weaponName.CompareTo("end") != 0)
            {
                Console.WriteLine("Please enter the Range of the Weapon (0-10):");
                weaponRange = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Please enter the Damage of the Weapon:");
                weaponDamage = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Please enter the Weight of the Weapon (in pounds):");
                weaponWeight = Convert.ToDouble(Console.ReadLine());
                Console.WriteLine("Please enter the Cost of the Weapon:");
                weaponCost = Convert.ToDouble(Console.ReadLine());
                Weapon w = new Weapon(weaponName, weaponRange, weaponDamage, weaponWeight, weaponCost);
                h.put(w);
                Console.WriteLine("Please enter the NAME of another Weapon ('end' to quit):");
                weaponName = Console.ReadLine();
            }
        }