Пример #1
0
 public static int getItemID(Item item) {
   for (int i = 0; i < allTheItems.length; ++i) {
     if (item.toString().equalsIgnoreCase(allTheItems[i].toString())) {
       return i;
     }
   }
   throw new UncheckedDemigodsException(
       "Item " + item + " does not have a spot in the ID list. Check the spelling.");
 }
Пример #2
0
 public static Item getItemFromString(String s) throws DemigodsException {
   Item item = null;
   for (Item i : allTheItems) {
     if (i.toString().equalsIgnoreCase(s)) {
       item = i;
       break;
     }
   }
   if (item == null) throw new DemigodsException("Item not found.");
   return item;
 }