Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
project2pentago
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
9831113
project2pentago
Commits
0b662ace
Commit
0b662ace
authored
Apr 12, 2020
by
amir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
completing methods
parent
a744669e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
Player.java
Player.java
+35
-0
No files found.
Player.java
View file @
0b662ace
...
...
@@ -45,6 +45,10 @@ public class Player {
playerCoordinate
[
x
][
y
]++;
}
/**
* Checks if the match ends or not
* @return true if the match already ends and false if the match should be continued
*/
public
boolean
searchIfMatchEnds
(){
for
(
int
i
=
0
;
i
<
6
;
i
++){
for
(
int
j
=
0
;
j
<
6
;
j
++){
...
...
@@ -57,6 +61,12 @@ public class Player {
return
false
;
}
/**
*
* @param x
* @param y
* @return
*/
public
boolean
checkSides
(
int
x
,
int
y
){
if
(
x
!=
0
){
if
(
containsInArray
(
playerCoordinate
,
x
-
1
,
y
)){
...
...
@@ -105,6 +115,15 @@ public class Player {
return
false
;
}
/**
* draws a line from x, y coordinate from a player's disc into
* specified direction to check if there is 5 in a line returns 5
* @param x the x of the coordinate
* @param y the y of the coordinate
* @param moveX the exact direct into x axis
* @param moveY the exact direct into y axis
* @return the number of discs of the player in a line
*/
public
int
countTheMoves
(
int
x
,
int
y
,
int
moveX
,
int
moveY
){
int
x1
=
x
+
moveX
;
int
y1
=
y
+
moveY
;
...
...
@@ -118,6 +137,11 @@ public class Player {
return
counter
;
}
/**
* displays the visualMap
* @param arr the coordinates of player1's discs
* @param arr2 the coordinates of player2's discs
*/
public
void
display
(
byte
[][]
arr
,
byte
[][]
arr2
){
System
.
out
.
println
(
" 0 1 2 3 4 5"
);
for
(
int
i
=
0
;
i
<
3
;
i
++){
...
...
@@ -164,6 +188,10 @@ public class Player {
}
}
/**
* gets the coordinate domain of the board from the "searchCoordinate" method and rotates 90 degrees clockwise
* @param boardNumber the number of board to rotate
*/
public
void
rotate
(
byte
boardNumber
){
byte
[]
bytes
=
new
byte
[
2
];
bytes
=
searchCoordinate
(
boardNumber
);
...
...
@@ -184,6 +212,13 @@ public class Player {
playerCoordinate
[
bytes
[
0
]][
bytes
[
1
]
+
1
]
=
tmp2
;
}
/**
* gets a board number and returns a byte array that the first
* index is the x of board's coordinate and the last
* index is the y of board's coordinate
* @param boardNumber number of board to search
* @return the byte array
*/
public
byte
[]
searchCoordinate
(
byte
boardNumber
){
byte
[]
c
=
new
byte
[
2
];
switch
(
boardNumber
){
...
...
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