forked from AllenDowney/ThinkJavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTile.java
More file actions
48 lines (38 loc) · 824 Bytes
/
Copy pathTile.java
File metadata and controls
48 lines (38 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
public class Tile {
/**
*Represents Scrabble tiles
*/
private char letter;
private int score;
public Tile(char letter, int score) {
this.letter = letter;
this.score = score;
}
public String toString() {
return String.format("\"%c\": %d points\n",
this.letter, this.score);
}
public boolean equals(Tile that) {
return this.letter == that.letter
&& this.score == that.score;
}
public char getLetter() {
return this.letter;
}
public int getScore() {
return this.score;
}
public void setLetter(char letter) {
this.letter = letter;
}
public void setScore(int score) {
this.score = score;
}
public static void printTile(Tile t) {
System.out.printf("\"%c\":%d points\n", t.letter, t.score);
}
public static void testTile() {
Tile z = new Tile('Z', 10);
printTile(z);
}
}