-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSquare.java
71 lines (57 loc) · 1.29 KB
/
Square.java
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package Squares;
import GameComponents.Coord;
import GameComponents.Tile;
public class Square {
private Coord coordinates;
private char letter;
private boolean occupied;
private Tile assignedTile;
// empty square
public Square() {
this.letter = '_';
this.assignedTile = null;
this.occupied = false;
}
// square with tile on it
public Square(Tile tile, Coord coordinates) {
this.coordinates = coordinates;
this.letter = tile.getLetter();
this.assignedTile = tile;
this.occupied = true;
}
// to undo the board if player has incorrect tile placement
public void setToNull() {
this.letter = '_';
this.assignedTile = null;
this.occupied = false;
}
public boolean isOccupied() {
return occupied;
}
public int getScore () {
return assignedTile.getLetterPoints();
}
public Coord getCoords() {
return coordinates;
}
public char getLetter() {
return letter;
}
public void paint() {
if (isOccupied())
System.out.print(getLetter() + " ");
else
System.out.print("_ ");
}
public Tile getAssignedTile() {
return assignedTile;
}
public void setAssignedTile(Tile tile) {
assignedTile = tile;
this.occupied = true;
this.letter = tile.getLetter();
}
public boolean equals (Square s) {
return ((this.assignedTile).equals(s.assignedTile));
}
}