Commit ee4795f4 authored by Haj Rezvan's avatar Haj Rezvan

Add javadoc and update version to 1.2

parent 99c69f92
......@@ -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;
}
......
......@@ -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
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);
......
public interface INuts {
char getColor();
void setNutsInBoard();
int getMergePosition();
......
......@@ -4,4 +4,5 @@
* @version 0.0
*/
public interface IPlayer {
int getColorCode();
}
\ No newline at end of file
/**
* 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;
......
/**
* 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment