Commit 13f1fbcc authored by amir's avatar amir

Finalized

parent cac6a3c1
package com.company;
public class Console extends Display {
public Console(byte displayType) {
super(displayType);
}
public class Console {
@Override
public void visualize() {
super.visualize();
System.out.println(" A B C D E F G H");
}
}
package com.company;
public class Graphic {
public class Graphic{
}
......@@ -6,10 +6,13 @@ public class Main {
public static void main(String[] args) {
int turns = 0;
System.out.println("What type of game do you want? 0)console 1)graphic");
Scanner scanner = new Scanner(System.in);
byte displayType = scanner.nextByte();
Players players = new Players();
Player1 play1 = new Player1();
Player2 play2 = new Player2();
players.display(play1.getArr1(), play2.getArr2());
players.display(play1.getArr1(), play2.getArr2(), displayType);
while ((play1.getNumberOfDisks(play1.getArr1()) + play2.getNumberOfDisks(play2.getArr2()) < 64) &&
(play1.getNumberOfDisks(play1.getArr1()) != 0) && (play2.getNumberOfDisks(play2.getArr2()) != 0))
{
......@@ -36,7 +39,6 @@ public class Main {
continue;
}
}
Scanner scanner = new Scanner(System.in);
String nl = scanner.nextLine();
char[] f = nl.toCharArray();
// scanning the x and y coordinates from user
......@@ -52,7 +54,7 @@ public class Main {
}
}
players.display(play1.getArr1(), play2.getArr2());
players.display(play1.getArr1(), play2.getArr2(), displayType);
//System.out.println("player1: "+play1.getNumberOfDisks1()+" player2:"+play2.getNumberOfDisks2());
}
if (play1.getNumberOfDisks(play1.getArr1()) > play2.getNumberOfDisks(play2.getArr2()))
......
package com.company;
public class Player1 extends Players {
// the array of the player 1's coordinate
int[][] arr1;
/**
* Creates player1 with an initial deceleration
*/
public Player1(){
arr1 = new int[9][9];
arr1[4][5] = 1;
arr1[5][4] = 1;
}
/**
* returns the array of player1's coordinates
* @return the array of player1's coordinates
*/
public int[][] getArr1() {
return arr1;
}
......
package com.company;
public class Player2 extends Players {
// the array of the player 2's coordinate
int[][] arr2;
/**
* Creates player2 with an initial deceleration
*/
public Player2(){
arr2 = new int[9][9];
arr2[4][4] = 1;
arr2[5][5] = 1;
}
/**
* returns the array of player2's coordinates
* @return the array of player2's coordinates
*/
public int[][] getArr2() {
return arr2;
}
......
......@@ -84,10 +84,14 @@ public class Players {
* displays the place of black and white discs and blanks
* @param a1 array of the player1's discs
* @param a2 array of the player2's discs
* @param displayType type of display
*/
public void display(int[][] a1, int[][] a2){
public void display(int[][] a1, int[][] a2, byte displayType){
if (displayType == 0) {
System.out.println(" A B C D E F G H");
}
for (int i = 1; i <= 8; i++){
if (displayType == 0)
System.out.print(i+ " ");
for (int j = 1; j <= 8; j++) {
if (containsInArray(a2, j, i)) {
......@@ -166,12 +170,13 @@ public class Players {
}
/**
*
* @param arrOpponent
* @param arr
* @param x
* @param y
* @return
* checks the sides of the blank to see if there is an opponent disk or not
* and then goes to the "checkTheMoveIfPossible" method
* @param arrOpponent the coordinates of opponent's discs
* @param arr the coordinates of player's discs
* @param x the x coordinate of blank
* @param y the x coordinate of blank
* @return true if any of sides is allowed and false if none them
*/
public boolean checkSides(int[][] arrOpponent, int[][] arr, int x, int y){
if (x != 1){
......@@ -223,14 +228,14 @@ public class Players {
}
/**
*
* @param arrOpponent
* @param arr
* @param x
* @param y
* @param moveX
* @param moveY
* @return
* checks the move if possible :))
* @param arrOpponent the coordinates of opponent's discs
* @param arr the coordinates of player's discs
* @param x the x coordinate of blank
* @param y the x coordinate of blank
* @param moveX the direction in the x axis (0, 1 or -1)
* @param moveY the direction in the x axis (0, 1 or -1)
* @return if there is a possible move returns true and else returns false
*/
public boolean checkTheMoveIfPossible(int[][] arrOpponent, int[][]arr, int x, int y, int moveX, int moveY){
int x1 = x; int y1 = y;
......
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