Eight.java~1~
资源名称:Java.rar [点击查看]
上传用户:liming9091
上传日期:2014-10-27
资源大小:3376k
文件大小:2k
源码类别:
Java编程
开发平台:
Java
- public class Eight extends Root
- {
- private GameTable gTable;
- private int x,y;
- private int direct=1;
- private int[] store;
- public Eight()
- {
- store=new int[15];
- }
- public boolean begin()
- {
- if(gTable.myTable[(gTable.x-1)/2][0]==0)
- {
- x=(gTable.x-1)/2;
- y=0;
- gTable.myTable[x][y]=1;
- return true;
- }
- else
- {
- return false;
- }
- }
- public boolean down()
- {
- if(y<=gTable.y-2)
- {
- store[0]=gTable.myTable[x][y+1];
- if(isGo(1))
- {
- gTable.myTable[x][y]=0;
- gTable.myTable[x][y+1]=1;
- y+=1;
- return true;
- }
- else
- {
- return false;
- }
- }
- else
- {
- return false;
- }
- }
- public boolean left()
- {
- if(x>=1)
- {
- store[0]=gTable.myTable[x-1][y];
- if(isGo(1))
- {
- gTable.myTable[x][y]=0;
- gTable.myTable[x-1][y]=1;
- x-=1;
- return true;
- }
- else
- {
- return false;
- }
- }
- else
- {
- return false;
- }
- }
- public boolean right()
- {
- if(x<=gTable.x-2)
- {
- store[0]=gTable.myTable[x+1][y];
- if(isGo(1))
- {
- gTable.myTable[x][y]=0;
- gTable.myTable[x+1][y]=1;
- x+=1;
- return true;
- }
- else
- {
- return false;
- }
- }
- else
- {
- return false;
- }
- }
- public boolean change()
- {
- return true;
- }
- public void downTo()
- {
- boolean canDown=true;
- while(canDown)
- {
- canDown=down();
- }
- }
- public boolean isGo(int n)
- {
- for(int i=0;i<=(n-1);i++)
- {
- if(store[i]!=0)
- return false;
- }
- return true;
- }
- public static void main(String args[])
- {
- new Eight();
- }
- }