-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSquare.java
More file actions
100 lines (78 loc) · 1.7 KB
/
Copy pathSquare.java
File metadata and controls
100 lines (78 loc) · 1.7 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package edu.unlv.mis768.finalproject;
/**
* This class designs a single square of the chess board
* @author William Brasic and Sergio Torres
*
*/
public class Square {
// initialization of fields to be used in Square class
private Piece piece;
private int x;
private int y;
/**
* Constructor
* @param piece
* @param x
* @param y
*/
public Square(Piece piece, int x, int y){
this.setPiece(piece);
this.setX(x);
this.setY(y);
}
/**
* Get piece on square
* @return type of piece on the square
*/
public Piece getPiece(){
return this.piece;
}
/**
* Set piece on square
* @param p
*/
public void setPiece(Piece p){
this.piece = p;
}
/**This method checks if the square has a piece.
*
* @param p piece
* @return
*/
public boolean hasPiece() {
if (this.piece != null) {
return true;
}
else {
return false;
}
}
/**
* Get x coordinate of square
* @return x coordinate
*/
public int getX(){
return this.x;
}
/**
* Set x coordinate of square
* @param x
*/
public void setX(int x){
this.x = x;
}
/**
* Get y coordinate of square
* @return y coordinate
*/
public int getY(){
return this.y;
}
/**
* Set y coordinate of square
* @param y
*/
public void setY(int y){
this.y = y;
}
}