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
Show 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;
...
@@ -3,31 +3,38 @@ import java.io.IOException;
/**
/**
* This class represents status of board and update its.
* This class represents status of board and update its.
* @author Rezvanian 9831029
* @author Rezvanian 9831029
* @version
0
.2
* @version
1
.2
*/
*/
public
class
Board
implements
IBoard
{
public
class
Board
implements
IBoard
{
//constant variable, size of map
private
static
final
int
SIZE
=
9
;
private
static
final
int
SIZE
=
9
;
//for programmer
//for programmer
private
static
char
[]
map
=
new
char
[
81
];
private
static
char
[]
map
=
new
char
[
81
];
/*
/*
Access in version 0.1
Access in version 0.1
private char[] map;
private char[] map;
*/
*/
//for user
//for user
private
static
char
[][]
visualMap
=
new
char
[
4
*
9
+
1
][
8
*
9
+
1
];
private
static
char
[][]
visualMap
=
new
char
[
4
*
9
+
1
][
8
*
9
+
1
];
/*
/*
Access in version 0.1
Access in version 0.1
private char[][] visualMap;
private char[][] visualMap;
*/
*/
/**
/**
* This method, initialise the fields.
* This method, initialise the fields
and map
.
*/
*/
public
static
void
initialisingBoard
(){
public
static
void
initialisingBoard
(){
map
=
new
char
[
81
];
map
=
new
char
[
81
];
for
(
int
i
=
0
;
i
<
SIZE
*
SIZE
;
i
++){
for
(
int
i
=
0
;
i
<
SIZE
*
SIZE
;
i
++){
//initialise the map and set header of map
switch
(
i
){
switch
(
i
){
case
0
:{
case
0
:{
map
[
i
]
=
'+'
;
map
[
i
]
=
'+'
;
...
@@ -88,6 +95,7 @@ public class Board implements IBoard {
...
@@ -88,6 +95,7 @@ public class Board implements IBoard {
}
}
visualMap
=
new
char
[
4
*
SIZE
+
1
][
8
*
SIZE
+
1
];
visualMap
=
new
char
[
4
*
SIZE
+
1
][
8
*
SIZE
+
1
];
//initialise the visualMap
for
(
int
xRow
=
0
;
xRow
<=
4
*
SIZE
;
xRow
++){
for
(
int
xRow
=
0
;
xRow
<=
4
*
SIZE
;
xRow
++){
for
(
int
yColumn
=
0
;
yColumn
<=
8
*
SIZE
;
yColumn
++){
for
(
int
yColumn
=
0
;
yColumn
<=
8
*
SIZE
;
yColumn
++){
if
(
xRow
%
4
==
0
){
if
(
xRow
%
4
==
0
){
...
@@ -125,14 +133,23 @@ public class Board implements IBoard {
...
@@ -125,14 +133,23 @@ public class Board implements IBoard {
visualMap
[
34
][
4
]
=
'8'
;
visualMap
[
34
][
4
]
=
'8'
;
}
}
/**
* This method get map.
* */
public
char
[]
getMap
()
{
public
char
[]
getMap
()
{
return
map
;
return
map
;
}
}
/**
* this method get visual map
* */
public
char
[][]
getVisualMap
()
{
public
char
[][]
getVisualMap
()
{
return
visualMap
;
return
visualMap
;
}
}
/**
* this method clear the screen and print the map.
* */
static
public
void
printMap
()
throws
IOException
,
InterruptedException
{
static
public
void
printMap
()
throws
IOException
,
InterruptedException
{
//clear terminal for refresh.
//clear terminal for refresh.
...
@@ -162,6 +179,10 @@ public class Board implements IBoard {
...
@@ -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
){
public
int
searchPosition
(
char
c
){
switch
(
c
){
switch
(
c
){
case
'A'
:{
case
'A'
:{
...
@@ -194,19 +215,33 @@ public class Board implements IBoard {
...
@@ -194,19 +215,33 @@ public class Board implements IBoard {
}
}
}
}
/**
* this method refresh of map
* */
public
static
void
refresh
()
throws
IOException
,
InterruptedException
{
public
static
void
refresh
()
throws
IOException
,
InterruptedException
{
printMap
();
printMap
();
}
}
/**
* this method check end of the game.
* */
public
static
boolean
checkEndOfGame
(){
public
static
boolean
checkEndOfGame
(){
boolean
validate
=
true
;
boolean
validate
=
true
;
return
validate
;
return
validate
;
}
}
/**
* this method set value of "visualMap".
* @param map is value of visualMap field.
* */
public
void
setVisualMap
(
char
[][]
map
)
{
public
void
setVisualMap
(
char
[][]
map
)
{
visualMap
=
map
;
visualMap
=
map
;
}
}
/**
* this method set value of "map".
* @param map2 is value of map field.
* */
public
void
setMap
(
char
[]
map2
)
{
public
void
setMap
(
char
[]
map2
)
{
map
=
map2
;
map
=
map2
;
}
}
...
...
GamePlay.java
View file @
ee4795f4
...
@@ -2,12 +2,11 @@ import java.io.IOException;
...
@@ -2,12 +2,11 @@ import java.io.IOException;
/**
/**
* This class, is main class in program.
* This class, is main class in program.
* The program started from hear.
* The program started from hear.
* @version
0
.2
* @version
1
.2
* @author Rezvanian 9831029
* @author Rezvanian 9831029
* */
* */
public
class
GamePlay
{
public
class
GamePlay
{
public
static
void
main
(
String
[]
args
)
throws
IOException
,
InterruptedException
{
public
static
void
main
(
String
[]
args
)
throws
IOException
,
InterruptedException
{
Board
.
initialisingBoard
();
Board
.
initialisingBoard
();
Nuts
nuts1B
=
new
Nuts
(
'b'
,
4
,
'D'
);
Nuts
nuts1B
=
new
Nuts
(
'b'
,
4
,
'D'
);
...
@@ -16,6 +15,14 @@ public class GamePlay {
...
@@ -16,6 +15,14 @@ public class GamePlay {
Nuts
nuts1W
=
new
Nuts
(
'w'
,
4
,
'E'
);
Nuts
nuts1W
=
new
Nuts
(
'w'
,
4
,
'E'
);
Nuts
nuts2W
=
new
Nuts
(
'w'
,
5
,
'D'
);
Nuts
nuts2W
=
new
Nuts
(
'w'
,
5
,
'D'
);
Player
player1
=
new
Player
(
1
);
Player
player2
=
new
Player
(
0
);
Board
.
refresh
();
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
;
import
java.io.IOException
;
/**
/**
* This interface, has declaration of method in Board class
* This interface, has declaration of method in Board class
* @version
0
.2
* @version
1
.2
* @author Rezvanian 9831029
* @author Rezvanian 9831029
* */
* */
public
interface
IBoard
{
public
interface
IBoard
{
...
@@ -10,8 +10,10 @@ public interface IBoard {
...
@@ -10,8 +10,10 @@ public interface IBoard {
static
void
printMap
()
throws
IOException
,
InterruptedException
{
static
void
printMap
()
throws
IOException
,
InterruptedException
{
}
}
// void setMapByPosition(int position, char nut);
// 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
);
int
searchPosition
(
char
c
);
void
setMap
(
char
[]
map
);
void
setMap
(
char
[]
map
);
void
setVisualMap
(
char
[][]
visualMap
);
void
setVisualMap
(
char
[][]
visualMap
);
...
...
INuts.java
View file @
ee4795f4
public
interface
INuts
{
public
interface
INuts
{
char
getColor
();
char
getColor
();
void
setNutsInBoard
();
void
setNutsInBoard
();
int
getMergePosition
();
int
getMergePosition
();
...
...
IPlayer.java
View file @
ee4795f4
...
@@ -4,4 +4,5 @@
...
@@ -4,4 +4,5 @@
* @version 0.0
* @version 0.0
*/
*/
public
interface
IPlayer
{
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.
* This class represent status of nuts, and add them to map.
* @author Rezvanian 9831029
* @author Rezvanian 9831029
* @version
0.1
* @version
1.2
*/
*/
public
class
Nuts
extends
Board
implements
INuts
{
public
class
Nuts
extends
Board
implements
INuts
{
private
char
color
;
private
char
color
;
//This field is for "map" field in super class
//This field is for "map" field in super class
private
int
MergePosition
;
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
x
;
private
int
y
;
private
int
y
;
...
...
Player.java
View file @
ee4795f4
/**
/**
* This class represents status and information of players.
* This class represents status and information of players.
* @author Rezvanian 9831029
* @author Rezvanian 9831029
* @version
0.0
* @version
1.2
*/
*/
public
class
Player
implements
IPlayer
{
public
class
Player
implements
IPlayer
{
private
int
colorCode
;
//Color code for white is 1 and for black is 0
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