我这里有两个类,在我的 Player 类中,我想从 Scoresheet 类中获取这些类的总数。我不知道该怎么做。
public class ScoreSheet {
public int getOnes(ArrayList<Integer> die)
{
for (int i = 0; i < die.size(); i++)
{
if (die.get(i) == 1)
{
ones++;
}
}
return ones;
}
public class Player {
private int ones = 0;
private int twos = 0;
private int threes = 0;
private int fours = 0;
private int fives = 0;
private int sixes = 0;
private int threeOfKind = 0;
private int fourOfKind = 0;
private int fullHouse = 0;
private int smallStraight = 0;
private int largeStraight = 0;
private int yahtzee = 0;
private int chance = 0;
public void checkScores(ArrayList<Integer> die)
{
ones = Player -> ScoreSheet.getOnes(<Integer> die); // this is wrong, need to know
// how to get total
}