Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Project_part1_Rezvanian_9831029
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
9831029
Project_part1_Rezvanian_9831029
Commits
ee4795f4
Commit
ee4795f4
authored
Apr 06, 2020
by
Haj Rezvan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add javadoc and update version to 1.2
parent
99c69f92
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
76 additions
and
11 deletions
+76
-11
Board.java
Board.java
+38
-3
GamePlay.java
GamePlay.java
+9
-2
IBoard.java
IBoard.java
+4
-2
INuts.java
INuts.java
+0
-1
IPlayer.java
IPlayer.java
+1
-0
Nuts.java
Nuts.java
+5
-2
Player.java
Player.java
+19
-1
No files found.
Board.java
View file @
ee4795f4
...
...
@@ -3,31 +3,38 @@ import java.io.IOException;
/**
* This class represents status of board and update its.
* @author Rezvanian 9831029
* @version
0
.2
* @version
1
.2
*/
public
class
Board
implements
IBoard
{
//constant variable, size of map
private
static
final
int
SIZE
=
9
;
//for programmer
private
static
char
[]
map
=
new
char
[
81
];
/*
Access in version 0.1
private char[] map;
*/
//for user
private
static
char
[][]
visualMap
=
new
char
[
4
*
9
+
1
][
8
*
9
+
1
];
/*
Access in version 0.1
private char[][] visualMap;
*/
/**
* This method, initialise the fields.
* This method, initialise the fields
and map
.
*/
public
static
void
initialisingBoard
(){
map
=
new
char
[
81
];
for
(
int
i
=
0
;
i
<
SIZE
*
SIZE
;
i
++){
//initialise the map and set header of map
switch
(
i
){
case
0
:{
map
[
i
]
=
'+'
;
...
...
@@ -88,6 +95,7 @@ public class Board implements IBoard {
}
visualMap
=
new
char
[
4
*
SIZE
+
1
][
8
*
SIZE
+
1
];
//initialise the visualMap
for
(
int
xRow
=
0
;
xRow
<=
4
*
SIZE
;
xRow
++){
for
(
int
yColumn
=
0
;
yColumn
<=
8
*
SIZE
;
yColumn
++){
if
(
xRow
%
4
==
0
){
...
...
@@ -125,14 +133,23 @@ public class Board implements IBoard {
visualMap
[
34
][
4
]
=
'8'
;
}
/**
* This method get map.
* */
public
char
[]
getMap
()
{
return
map
;
}
/**
* this method get visual map
* */
public
char
[][]
getVisualMap
()
{
return
visualMap
;
}
/**
* this method clear the screen and print the map.
* */
static
public
void
printMap
()
throws
IOException
,
InterruptedException
{
//clear terminal for refresh.
...
...
@@ -162,6 +179,10 @@ public class Board implements IBoard {
}
*/
/**
* this method get the character and search the where is position nut.
* @param c is character that we want to search position of its.
* */
public
int
searchPosition
(
char
c
){
switch
(
c
){
case
'A'
:{
...
...
@@ -194,19 +215,33 @@ public class Board implements IBoard {
}
}
/**
* this method refresh of map
* */
public
static
void
refresh
()
throws
IOException
,
InterruptedException
{
printMap
();
}
/**
* this method check end of the game.
* */
public
static
boolean
checkEndOfGame
(){
boolean
validate
=
true
;
return
validate
;
}
/**
* this method set value of "visualMap".
* @param map is value of visualMap field.
* */
public
void
setVisualMap
(
char
[][]
map
)
{
visualMap
=
map
;
}
/**
* this method set value of "map".
* @param map2 is value of map field.
* */
public
void
setMap
(
char
[]
map2
)
{
map
=
map2
;
}
...
...
GamePlay.java
View file @
ee4795f4
...
...
@@ -2,12 +2,11 @@ import java.io.IOException;
/**
* This class, is main class in program.
* The program started from hear.
* @version
0
.2
* @version
1
.2
* @author Rezvanian 9831029
* */
public
class
GamePlay
{
public
static
void
main
(
String
[]
args
)
throws
IOException
,
InterruptedException
{
Board
.
initialisingBoard
();
Nuts
nuts1B
=
new
Nuts
(
'b'
,
4
,
'D'
);
...
...
@@ -16,6 +15,14 @@ public class GamePlay {
Nuts
nuts1W
=
new
Nuts
(
'w'
,
4
,
'E'
);
Nuts
nuts2W
=
new
Nuts
(
'w'
,
5
,
'D'
);
Player
player1
=
new
Player
(
1
);
Player
player2
=
new
Player
(
0
);
Board
.
refresh
();
//check end of the game
do
{
}
while
(
Board
.
checkEndOfGame
());
}
}
\ No newline at end of file
IBoard.java
View file @
ee4795f4
import
java.io.IOException
;
/**
* This interface, has declaration of method in Board class
* @version
0
.2
* @version
1
.2
* @author Rezvanian 9831029
* */
public
interface
IBoard
{
...
...
@@ -10,8 +10,10 @@ public interface IBoard {
static
void
printMap
()
throws
IOException
,
InterruptedException
{
}
// void setMapByPosition(int position, char nut);
// void setVisualMapByPosition(int xPosition, int yPosition, char nut);
// void setVisualMapByPosition(int xPosition, int yPosition, char nut);
int
searchPosition
(
char
c
);
void
setMap
(
char
[]
map
);
void
setVisualMap
(
char
[][]
visualMap
);
...
...
INuts.java
View file @
ee4795f4
public
interface
INuts
{
char
getColor
();
void
setNutsInBoard
();
int
getMergePosition
();
...
...
IPlayer.java
View file @
ee4795f4
...
...
@@ -4,4 +4,5 @@
* @version 0.0
*/
public
interface
IPlayer
{
int
getColorCode
();
}
\ No newline at end of file
Nuts.java
View file @
ee4795f4
/**
* This class represent status of nuts, and add them to map.
* @author Rezvanian 9831029
* @version
0.1
* @version
1.2
*/
public
class
Nuts
extends
Board
implements
INuts
{
private
char
color
;
//This field is for "map" field in super class
private
int
MergePosition
;
//This fields is for "visualMap" field in super class
//This fields are for "visualMap" field in super class
private
int
x
;
private
int
y
;
...
...
Player.java
View file @
ee4795f4
/**
* This class represents status and information of players.
* @author Rezvanian 9831029
* @version
0.0
* @version
1.2
*/
public
class
Player
implements
IPlayer
{
private
int
colorCode
;
//Color code for white is 1 and for black is 0
private
boolean
playerTurn
;
private
int
intPlayerTurn
;
public
Player
(
int
color
){
colorCode
=
color
;
}
public
int
getColorCode
()
{
return
colorCode
;
}
public
void
setPlayerTurn
(
boolean
playerTurn
)
{
this
.
playerTurn
=
playerTurn
;
}
public
void
setColorCode
(
int
colorCode
)
{
this
.
colorCode
=
colorCode
;
}
}
\ No newline at end of file
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