为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

Rogerl 2015-07-22 17:58:45
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());//这行出错了 }}
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 1785 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信