宾果游戏号码类别:接收错误

时间:2019-03-07 07:09:50

标签: java performance compiler-errors

该项目的目标是创建一个管理Bingo游戏的宿主程序。每一轮游戏中,可以有许多玩家。在游戏的一轮中,玩家可以拥有任意数量的Bingo卡。我需要创建不同的类以供输入我的main方法。现在,我正在研究Bingo号码类,其目的是获得可以由玩家标记的Bingo号码。我不断获取int不能被取消引用的错误。这是我的代码:

public class BingoNumber
{
   private int number;
   private boolean [][] mark;
   private int [][] card;

 //Constructor constructs an object of type BingoNumber 
 public BingoNumber(int aNumber)
 {
    card = new int [5][5];
    for(int r = 0; r < 5; r++)
    for(int c = 0; c < 5; c++)
    card[r][c]=(int)(Math.random()*75+1);

    mark = new boolean [5] [5];
    for(int r = 0; r < 5; r++)
    for(int c = 0; c < 5; c++)
    mark[r][c] = false;

    number = aNumber;
 }
//returns the integer representing the number of the BingoNumber. 
public int getNumber() 
{
    return number;
}
//returns true or false whether the number is marked
public boolean isMarked() 
{
    for(int r = 0; r < 5; r++)
    for(int c = 0; c < 5; c++)
    if(card[r][c] == number)
    {
        mark[r][c] = true;  
        return mark[r][c];
    }
    else
        return mark[r][c];
}
/*returns a two-digit string presentation of a BingoNumber. 
 The output string depends on whether the number is marked. 
 If the number is not marked yet, shows the number. 
 If the number is marked, the output string will XX. **/
public String toString() 
{   
    StringBuilder s = new StringBuilder ();
    s.append(number);
    //getting int cannot be dereferenced
    s.append("XX" + number.isMarked()); 
    return s.toString();
}
/*Returns a two-digit string representation of a BingoNumber 
  as if it has not been marked yet.*/
public String toNumberString() 
{
    StringBuilder s = new StringBuilder ();
    s.append(number);
}
//Notes that once the number is marked it cannot be unmarked. 
/*Later in a future class there will be method that will 
  let users unmark a Bingo number.*/
public void mark()    
{
    for (int i = 0; i < card.length; i++)
    //int cannot be dereferenced
    card[i][i].isMarked(number); 
}

}

0 个答案:

没有答案