Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have been working on this a while now and am stuck. I am trying to find out wh

ID: 3768475 • Letter: I

Question

I have been working on this a while now and am stuck. I am trying to find out why I have this error

public class BingoBall
{
private char column;
private int value;
private boolean marked;
  
//-----------------------------------------------------------------
// Sets up this BINGO ball wth the specified valueber and the
// appropriate column.
//-----------------------------------------------------------------
public BingoBall (int val, char column)
{
value = val;
  
if (val <= 15)
column = 'B';
else
if (val <= 30)
column = 'I';
else
if (val <= 45)
column = 'N';
else
if (val <= 60)
column = 'G';
else
column = 'O';
}
public char getColumn()
{
return column;
}
public int getValue()
{
return value;
}
public void setMarked(boolean n)
{
  
for(int i = 0; i < 5; i++)
{
  
for(int j = 0; j < 5; j++)
{

boolean value = (i != 0);
if(value == n)
{
  
marked = true;
  
break;
  
}
}
}
}
public boolean getMarked()
{
return marked;

}
//-----------------------------------------------------------------
// Returns a string representation of this BINGO ball.
//-----------------------------------------------------------------
public String toString ()
{
return (column + " " + value);
}
}

*******************************************************

import java.util.*;


class BingoCard
{
private BingoBall [][] card = new BingoBall[5][5];

//Constructor that initializes a standard bingo card.
BingoCard ()
{
for (int i = 0; i < card.length; i++)
{
addUniqueBall(1, 15, i, 0, 'B');
addUniqueBall(16, 30, i, 1, 'I');
addUniqueBall(31, 45, i, 2, 'N');
addUniqueBall(46, 60, i, 3, 'G');
addUniqueBall(61, 75, i, 4, 'O');
}
}

//If the given ball is on the card, marks it as played
public boolean mark (BingoBall ball)
{
for (int i = 0; i < card.length; i++)
{   
for (int j = 0; j < card[i].length; j++)
{
BingoBall b = card[i][j];
if (b.equals(ball))
{
card[i][j].setMarked(true);
return true;
}
}
}
  
return false;
}
  
//returns true if any row, column, or diagonal is marked
public boolean isBingo ()
{
for (int i = 0; i < card.length; i++)
{
if (colIsMarked(i) || rowIsMarked(i))
return true;
}
  
if (diagonalLeftToRightIsMarked())
return true;
  
if (diagonalRightToLeftIsMarked())
return true;
  
return false;
}
  
//returns true if the given column is marked
private boolean colIsMarked (int col)
{
for (int row = 0; row < card[col].length; row++)
{
if (! card[row][col].getMarked())
return false;
}
  
return true;
}

//returns true if the given row is marked
private boolean rowIsMarked (int row)
{
for (int col = 0; col < card.length; col++)
{
if (! card[row][col].getMarked())
return false;
}
  
return true;
}
  
//returns true if the left to right diagonal is marked
private boolean diagonalLeftToRightIsMarked ()
{
for (int i = 0; i < card.length; i++)
{
if (! card[i][i].getMarked())
return false;
}
  
return true;
}

//returns true if the right to left diagonal is marked
private boolean diagonalRightToLeftIsMarked ()
{
for (int i = 0, j = card.length - 1; i < card.length && j >= 0; i++, j--)
{
if (! card[i][j].getMarked())
return false;
}
  
return true;
}
  
// returns truw if the given number is used in the given column
private boolean numberIsUsed (int col, int number)
{
for (int i = 0; i < card[col].length; i++)
{
BingoBall ball = card[i][col];
if (ball != null && ball.getValue() == number)
return true;
}

return false;
}

// adds a ball in the correct range at the given position for the given column designation
private void addUniqueBall (int min, int max, int row, int col, char c)
{
Random random = new Random();
int next;
  
// System.out.println(row + " " + col + " " + c);
  
do
{
next = random.nextInt(max - min + 1) + min;
} while (numberIsUsed(col, next));

card[row][col] = new BingoBall(c, next);
}


//Converts the card to a string representation. If a spot is marked, 0 is used,
//otherwise the numeric value is used.
public String toString ()
{
String s = String.format("%-4c%-4c%-4c%-4c%-4c ", 'B', 'I', 'N', 'G', 'O');

for (int i = 0; i < card.length; i++)
{   
for (int j = 0; j < card[i].length; j++)
{
BingoBall b = card[i][j];
if (! b.getMarked())
s += String.format("%-4d", b.getValue());
else
s += String.format("%-4d", 0);
}

s += " ";
}

return s;
}

public static void main(String[] args)
{
for (int i =0; i < 10; i++)
{
BingoCard card = new BingoCard();

System.out.println(card);
}
}
}

Error: The constructor BingoBall (char, int) is undefined

Explanation / Answer

I think problem is decleration of BingoBall constructor. You just need to reverse the arguments, hope it should work now.

public BingoBall (char column, int val)
{
value = val;
  
if (val <= 15)
column = 'B';
else
if (val <= 30)
column = 'I';
else
if (val <= 45)
column = 'N';
else
if (val <= 60)
column = 'G';
else
column = 'O';
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote