示例#1
0
 public void addTown(Town town) throws AlreadyRegisteredException {
   if (hasTown(town)) throw new AlreadyRegisteredException();
   else {
     towns.add(town);
     town.setWorld(this);
   }
 }
示例#2
0
 public void removeTown(Town town) throws NotRegisteredException {
   if (!hasTown(town)) throw new NotRegisteredException();
   else {
     towns.remove(town);
     try {
       town.setWorld(null);
     } catch (AlreadyRegisteredException e) {
     }
   }
 }