U E D R , A S I H C RSS

Java Study2002/세연-2주차

~cpp 
// import java.*;
import java.util.*;


class Direction{
	int m_nRow;
	int m_nCol;
	void set(int row, int col){
		m_nRow = row;
		m_nCol = col;
	}
}


class Horse{
	int nMaxNum = 8;
	int row, col, dir;
	
	Board cBoard = new Board();
	Direction [] direction = new Direction[nMaxNum];
	
		
	
	void setDirection(){
		direction[0].set(1,0);
		direction[1].set(1,1);
		direction[2].set(0,1);
		direction[3].set(-1,1);
		direction[4].set(-1,0);
		direction[5].set(-1,-1);
		direction[6].set(0,-1);
		direction[7].set(1,-1);		
	}
	
	void setFirstPosition(int firstRow, int firstCol){
		row = firstRow;
		col = firstCol;		
	}
	
    public void move(){
		//난수를 발생시킨다
		Random random = new Random();
		
		dir = random.nextInt() % 8;
		
		row = row + direction[dir].m_nRow;
		col = col + direction[dir].m_nCol;	
	}
	
	void setMyPosition(){
	}
}

class Board{
	int nMaxNum = 8;
	int [][] board = new int[nMaxNum+2][];
	
	void markPosition(int rowPositoin, int colPosition){
		
		
	}
	void isThisPositionRight(){
	}
	void isTheGameFinished(){
	}
}

public class RandomWalk{
	public static void main(String[] args){
		Horse horse = new Horse();
		horse.setFirstPosition(4,4);
	
	}
}

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:30
Processing time 0.0129 sec