⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chess.java

📁 thinking in java 经典书的习题答案 希望对大家有帮助啊
💻 JAVA
字号:
// reusing/Chess.java
// TIJ3 Chapter Reusing, Exercise 6, page 246
/* Using Chess.java, prove the statements in the previous paragraph. (If you
* don't call the base class constructor in BoardGame(), the compiler will
* complain that it can't find a constructor of the form Game(). In addition, the
* call to the base-class constructor must be the first thin you do in the
* derived-class constructor. The compiler will remind you if you get it wrong.)
*/
import static net.mindview.util.Print.*;

class Game {
	Game(int i) {
		print("Game constructor");
	}	
}

class BoardGame extends Game {
	BoardGame(int i) {
		// print("BoardGame constructor"); // call to super must be first
			// statement in constructor 
		super(i); // else: "cannot find symbol: constructor Game()
		print("BoardGame constructor");
	}
}

public class Chess extends BoardGame {
	Chess() {
		super(11);
		print("Chess constructor");
	}
	public static void main(String[] args) {
		Chess x = new Chess();
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -