package com.newlecture.game;


public class OmokBoard {

private char [][]buf;  

private char [][]om;

private int width;

private int height;

private int count;

public OmokBoard(int width, int height) //생성자 - 초기값설정

{

count = 0;

buf = new char[30][40];

this.width = width;

this.height = height;

for(int i=0; i<height; i++)

for(int j=0; j<width; j++)

{

if(i==0 && j==0)

{

buf[i][j] = '┌';

}

else if (i ==height-1 && j==width-1)

{

buf[i][j] = '┘';

}

else if (i ==height-1 && j==0)

{

buf[i][j] = '└';

}

else if (i ==0&& j==width-1)

{

buf[i][j] = '┐';

}

else if (i ==0)

{

buf[i][j] = '┬';

}

else if (j==0)

{

buf[i][j] = '├';

}

else if (i==height-1)

{

buf[i][j] = '┴';

}

else if (j==width-1)

{

buf[i][j] = '┤';

}

else  

buf[i][j] = '┼';

}

}

public void print()

{

for(int i=0; i<height; i++)

{

for(int j=0; j<width; j++)

System.out.printf("%c",  buf[i][j]);

System.out.println();

}

}


public void put(Omok omok) 

{

int x=omok.getX();

int y=omok.getY();

if(buf[x-1][y-1] =='○' || buf[x-1][y-1] == '●')

System.out.println("다시놔주세요");

else if(count%2 == 0)

{

this.buf[x-1][y-1] = '●';

count++;

}

else

{

this.buf[x-1][y-1] = '○';

count++;

}

this.print();

}

}


+ Recent posts