📄 stormyinning29.java
字号:
// exceptions/StormyInning29.java
// TIJ4 Chapter Exceptions, Exercise 29, page 500
/* Modify all the exception types in StormyInning.java so that they extend
* RuntimeException, and show that no exception specifications or try blocks
* are necessary. Remove the '//!' comments and show how the methods can be
* compiled without specifications.
*/
class BaseballException extends RuntimeException {}
class Foul extends RuntimeException {}
class Strike extends RuntimeException {}
abstract class Inning {
public Inning() {}
public void event() {}
public abstract void atBat();
public void walk() {}
}
class StormException extends RuntimeException {}
class RainedOut extends RuntimeException {}
class PopFoul extends RuntimeException {}
interface Storm {
public void event();
public void rainHard();
}
public class StormyInning29 extends Inning implements Storm {
public StormyInning29() {}
public StormyInning29(String s) {}
public void walk() {}
public void event() {}
public void rainHard() {}
public void atBat() {}
public static void main(String[] args) {
StormyInning29 si = new StormyInning29();
si.atBat();
// What happens if you upcast?
Inning i = new StormyInning29();
i.atBat();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -