public static Vector<Pos> path;
public static void main(String[] args) {
// TODO 自动生成的方法存根
Scanner cin=new Scanner(System.in);
Side side=new Side();
path=side.move(0);
if(path!=null){
for(int i=path.size()-1;i>=0;i--){
int n=(path.size()-i-1);
System.out.println("第"+n+"步:");
display(path.get(i).dog_here, "dog"); //输出函数
display(path.get(i).cat_here, "cat ");
display(path.get(i).fish_here, "fish");
display(path.get(i).man_here,"man");
}
}else{
System.out.println("no result");
}
int input=cin.nextInt();
}
public static void display(Boolean b,String s){
if(!b){
System.out.println(" | |"+s);
}else{
System.out.println(s+" | | ");
}
}
}
class Side{ //定义一个Side类,4个boolean分别表示狗,猫,鱼,人的位置,ture表示在原来那边,false表示在对岸
public boolean dog_here=true;
public boolean cat_here=true;
public boolean fish_here=true;
public boolean man_here=true;
public Vector<Pos> path; //当按照规则成功到达对岸时,用于保存移动的路径
public int pathlength; //用于存储移动路径的长度,即步数
public static final int maxpath=10; //当步数过大依然没结果时终止程序,防止无限递归
public Side(Pos pos){ //接受前一个位置状态Pos的构造函数
this.dog_here=pos.dog_here;
this.cat_here=pos.cat_here;
this.fish_here=pos.fish_here;
this.man_here=pos.man_here;
}
public Side(){}