Unresolved compilation problem结果为什么树上是输出三次,我只想到输出一次!!

public class aa {

public static void playGame(GameFactory factory) {

Game s = factory.getGame();

while (s.move())

;

}

interface Game {

boolean move();

}

interface GameFactory {

Game getGame();

}


class Checkers implements Game {

private int moves = 0;

private static final int MOVES = 4;

public boolean move() {

print("Checkers moves " + moves);

return ++moves != MOVES;

}

}


class CheckersFactory implements GameFactory {

public Game getGame() {

return new Checkers();

}

}


private void print(String string) {

// TODO Auto-generated method stub

print(string);

}


public static void main(String[] args) {

playGame(new CheckersFactory());//这行出错了

}

}


Rogerl
浏览 1786回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java