📄 fielddomino.java
字号:
// Introduced in Chapter 2/** A domino. */public class FieldDomino implements Domino { /** The number on the left end of the Domino. */ private int left; /** The number on the right end of the Domino. */ private int right; /** Initialize the left and right numbers on the Domino. */ public FieldDomino(int left, int right) { this.left = left; this.right = right; } public void flip() { int swap = left; left = right; right = swap; } public int getLeft() { return left; } public int getRight() { return right; } public String toString() { return left + "-" + right; } /** Create a Domino (0-6), print it, flip it, and print it again. */ public static void main(String[] args) { Domino bone = new FieldDomino(0, 6); System.out.println(bone.getLeft() + "-" + bone.getRight()); bone.flip(); System.out.println(bone.getLeft() + "-" + bone.getRight()); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -