32 lines
580 B
Java
32 lines
580 B
Java
![]() |
//: reuse/Chess.java
|
|||
|
// <20>2015 MindView LLC: see Copyright.txt
|
|||
|
// Inheritance, constructors and arguments.
|
|||
|
import static com.mindviewinc.util.Print.*;
|
|||
|
|
|||
|
class Game {
|
|||
|
Game(int i) {
|
|||
|
print("Game constructor");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
class BoardGame extends Game {
|
|||
|
BoardGame(int i) {
|
|||
|
super(i);
|
|||
|
print("BoardGame constructor");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public class Chess extends BoardGame {
|
|||
|
Chess() {
|
|||
|
super(11);
|
|||
|
print("Chess constructor");
|
|||
|
}
|
|||
|
public static void main(String[] args) {
|
|||
|
Chess x = new Chess();
|
|||
|
}
|
|||
|
} /* Output:
|
|||
|
Game constructor
|
|||
|
BoardGame constructor
|
|||
|
Chess constructor
|
|||
|
*///:~
|