forked from Labore/PR2-L
17 lines
417 B
Java
17 lines
417 B
Java
class SwingException extends Exception {}
|
|
class CloseException extends Exception {}
|
|
|
|
class Door implements AutoCloseable {
|
|
|
|
public void swing() throws Exception {
|
|
System.out.println("The door is becoming unhinged!");
|
|
close();
|
|
throw new SwingException();
|
|
}
|
|
|
|
public void close() throws Exception {
|
|
System.out.println("The door is now closed.");
|
|
throw new CloseException();
|
|
}
|
|
}
|