我有一份學校作業。我發現這個描述很模糊......如果有人會仔細閱讀並給我解釋,或者用老師以外的其他語言解釋每種方法,那麼我們將不勝感激。作業要求如下...注意:我只是發現他的描述太模糊。所以沒有即時通訊不要求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