おっと豚のゲームをしていました。エラーが発生しました: " cannot find symbol class name"
。それを見つけるのを手伝ってくれませんか。
public class Player
{
protected String name;
Scorekeeper sk;
// sk = new ScoreKeeper();
public Player(String name)
{
this.name = name;
//Scorekeeper sk = new ScoreKeeper();
sk = new ScoreKeeper();
}
public Player(){ }
public int getScore()
{
return sk.getGameTotal;
}
public String getName()
{
return name;
}
public int incScore(int rollValue)
{
sk.addToRoundTotal(rollValue);
return sk.getRoundTotal;
}
public int setScore()
{
return sk.resetRoundTable();
}
}
これは、クラスのオブジェクトを作成するクラスScoreKeeper
であり、他のクラスは
public class ScoreKeeper {
int gametotal = 0;
int roundtotal = 0;
public ScoreKeeper()
{
//gametotal = 0;
//roundtotal = 0;
}
public void addToGameTotal() {
gametotal += roundtotal;
resetRoundTotal();
}
public void addToRoundTotal(int value) {
roundtotal += value;
}
public void resetRoundTotal() {
roundtotal = 0;
}
public int getRoundTotal() {
return roundtotal;
}
public int getGameTotal() {
return gametotal;
}
}
クラスをコンパイルしようとすると
Player.java:5: cannot find symbol
symbol : class Scorekeeper
location: class Player
Scorekeeper sk;
^
1 error