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

I have this written out but having a problem on the calling of \"showNumberRow\"

ID: 3533400 • Letter: I

Question

I have this written out but having a problem on the calling of "showNumberRow" for the public void showNumber....how do I call the "printNumberRow"? Trying to figure out where I made a mistake, please help. Thank you.



public class Number

{

public static final int HELLO_PER_LINE = 6;

public static final int HIYOU = 8;

  

private int [][] numberBox;  

public Number( int [][] newNumberBox )

{

this.numberBox = new int [HIYOU][HELLO_PER_LINE];

setNumberBox(newNumberBox);   

  

public int [][] getNumberBox( )

{

int [][] boxCopy = new int [HIYOU][HELLO_PER_LINE];

for ( int r = 0; r < this.numberBox.length; r++ )

{

for ( int c = 0; c < this.numberBox[r].length; c++ )

{

boxCopy[r][c] = this.numberBox[r][c];

}

}

return boxCopy;

}

/** mutator

* @param newNumberBox - array of BOX_SIZE

*

* Copies all newNumberBox elements to this.numberBox array.

* Assumes that both arrays are of the same size.

* Makes sure that the new values are either 0 or 1.

* In case of incorrect value uses 0 as the default.

*/

public void setNumberBox( int [][] newNumberBox )

{

  

for(int i = 0; i < this.numberBox.length; i++)

{

for (int j = 0; j < this.numberBox[i].length; j++)

{

this.numberBox[i][j] = newNumberBox[i][j];

}

}   

}

  

public String toString( )

{

String returnString = " ";

  

for(int i = 0; i < this.numberBox.length; i++)

{

for(int j = 0; j < this.numberBox[i].length; j++)

{

returnString+= this.numberBox[i][j] + " ";

}

returnString+= " ";

}

// IMPLEMENT THE METHOD

return returnString;

}

/** equals

* @param other another Number object

* @return true if this.numberBox elements are equal to the

* corresponding elements in other.numberBox

*/

public boolean equals( Number other )

{

boolean isEqual = true;

int [][] second = other.getNumberBox();

  

if(this.numberBox.length != second.length)

{

isEqual = false;

}

for(int i = 0; i < this.numberBox.length; i++)

{

if(this.numberBox[i].length != second[i].length)

isEqual = false;

for(int j = 0; j < this.numberBox[i].length; j++)

{

if(this.numberBox[i][j] != second[i][j])

isEqual = false;

}

}

// IMPLEMENT THE METHOD

  

return isEqual;

}

  

/** showNumberRow - prints one row of the number box. Useful for printing words

* @param showNum - the line number (0 - 6) of the letter to print

* 0 -> space; 1 -> *

*/

public void showNumberRow( int showNum )

{

for(int i = 0; i < this.numberBox[showNum].length; i++)

{

System.out.println(" " + this.nuberBox[showNum][i]);

}   

// IMPLEMENT THE METHOD

}

  

/** showNumber

* prints the number box as HIYOU lines of HELLO_PER_LINE characters

* calls showNumberRow method to print one line at the time

* 0 -> space; 1 -> *

*/

public void showNumber( )

{

for(int i = 0; i < this.numberBox.length; i++)

{

System.out.println(" " + this.numberBox[i] + " ");

  

showNum.showNumberBox();

  

for(i = 0; i < this.numberBox.length; i++)

System.out.print(this.numberBox[i] + " ");

System.out.println();

}   

}

Explanation / Answer

in showNumber, the call should be


showNumberBox();


instead of showNum.showNumberBox();