我有一份学校作业。我发现这个描述很模糊......如果有人会仔细阅读并给我解释,或者用老师以外的其他语言解释每种方法,那么我们将不胜感激。作业要求如下...注意:我只是发现他的描述太模糊。所以没有即时通讯不要求code.thanks。作业概述说明
The players will be children of the following (partially defined) class:
public abstract class Player implements Comparable{
public String name; // name of player
public int id; // identifier for the player
protected int wins;
protected int losses;
protected int ties;
public abstract String play(Player opponent);
// returns one of "rock", "paper", or "scissors"
public void update(String myGesture,
String opponentGesture,
Player opponent);
// this method will update the player's stats
// (wins, losses, ties) based on the gestures (inputs)
// for a recent game played against opponent (also input)
public Player(String name, int id){...}
// constructor that initializes player's name and id
You will need to fill in the code for the constructor and the update methods for the Player class. You can add other "hidden" attributes and methods as you wish (Note: if you add things to Player, be sure it is something that ALL children classes will also use). You will also need to implement three classes that extend the Player class:
public class SimplePlayer extends Player{...}
// A SimplePlayer will always play the same
// gesture (either rock, paper, or scissors)
// in every game it plays, regardless
// of who its opponent is. The gesture is
// randomly chosen when the SimplePlayer is created.
public class RandomPlayer extends Player{...}
// A RandomPlayer will always play a random
// gesture (rock, paper, or scissors) in
// every game it plays, regardless of who
// its opponent is.
public class SmartPlayer extends Player{...}
// A SmartPlayer will try to use past knowledge
// of games played against a particular
// opponent when playing them again.
You can add any hidden attributes and methods to the children classes as you wish.
编辑:由于此类实现了Comparable,play()是比较不同手势的方法吗?
该网站主要是为了代码。这听起来像你应该问你的老师。 – chris 2013-04-08 02:39:23
除非您有具体问题,否则我们无法为您提供帮助。这不是* Java翻译成简单英语的地方。例如,你知道'抽象类'是什么吗? – 2013-04-08 02:49:19