There’s a bit of confusion about the Exception subclasses defined in the Zork II design, which is understandable since they use inheritance and we haven’t covered that yet.
Let me make it easy for you. You should create a file called IllegalDungeonFormatException.java and put exactly these contents into it:
public class IllegalDungeonFormatException extends Exception {
public IllegalDungeonFormatException(String e) {
super(e);
}
}
Likewise, you should create a file called IllegalSaveFormatException.java and put exactly these contents into it:
public class IllegalSaveFormatException extends Exception {
public IllegalSaveFormatException(String e) {
super(e);
}
}
You should also create a file called NoRoomException.java with exactly these contents:
public class NoRoomException extends Exception {}
and finally, a NoExitException.java with these contents:
public class NoExitException extends Exception {}
Save those, make sure they compile (to catch typos), and commit them to your repo. From now on, whenever you discover a problem in a .zork file you’re hydrating (like, for instance, that the third line is anything other than literally “===“) you can write this code:
if (bad thing happens) {
throw new IllegalDungeonFormatException("Third line is not ===!");
}
Any time you read a .sav file and find something wrong (like, for instance, that there is no “Room states:” section), you can write this code:
if (other bad thing happens) {
throw new IllegalSaveFormatException("Missing 'Room states:' section!");
}
And of course when you reach the end of the rooms, or exits, while hydrating a Dungeon, you’ll be doing these things:
...
throw new NoRoomException();
and
...
throw new NoExitException();
exactly as described in chapter 10.