Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
chess
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
9611046
chess
Commits
f2b5d1a6
Commit
f2b5d1a6
authored
May 16, 2019
by
9611046
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
documentation for Square class
parent
db8d2b79
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
1 deletion
+36
-1
Square.java
src/game/Square.java
+36
-1
No files found.
src/game/Square.java
View file @
f2b5d1a6
...
...
@@ -18,6 +18,11 @@ public class Square extends JButton {
private
JLabel
image
;
private
boolean
possibleSquare
=
false
;
/**
*
* @param x x coordinate of square
* @param y y coordinate of square
*/
public
Square
(
int
x
,
int
y
){
this
.
x
=
x
;
this
.
y
=
y
;
...
...
@@ -25,6 +30,10 @@ public class Square extends JButton {
}
/**
*
* @param piece put a piece on a chess square
*/
public
void
setPiece
(
Piece
piece
)
{
this
.
piece
=
piece
;
hasPiece
=
true
;
...
...
@@ -33,32 +42,58 @@ public class Square extends JButton {
this
.
add
(
image
);
}
/**
* selects a square by redrawing its line border
*/
public
void
selectSquare
()
{
this
.
setBorder
(
BorderFactory
.
createLineBorder
(
Color
.
red
,
6
));
this
.
isSelected
=
true
;
}
/**
* deselects a square by deleting its red border line
*/
public
void
cancleSelection
(){
this
.
isSelected
=
tru
e
;
this
.
isSelected
=
fals
e
;
this
.
setBorder
(
null
);
}
/**
* makes a square possible for moving a piece by making its border line green
*/
public
void
makePossible
(){
this
.
setBorder
(
BorderFactory
.
createLineBorder
(
Color
.
green
,
6
));
this
.
possibleSquare
=
true
;
}
/**
* removes a piece of a square
*/
public
void
removePiece
(){
this
.
piece
=
null
;
this
.
remove
(
image
);
}
/**
*
* @return true if this square has a piece
*/
public
boolean
hasPiece
()
{
return
hasPiece
;
}
/**
* @return true if square is possible for moving a piece
*/
public
boolean
isPossibleSquare
()
{
return
possibleSquare
;
}
/**
*
* @return the piece of a square
*/
public
Piece
getPiece
(){
return
piece
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment