Question: Could someone please fix my code so that these methods run and makes my teris bricks deltete once one of the rows are full and

Could someone please fix my code so that these methods run and makes my teris bricks deltete once one of the rows are full and makes the row above move down? This is not my full code I just provided what I thought was neccessary to get this part correct.
rowHasSpace( int rowNumber)- returns true if there
is a space in the row of the board. This is used to determine
if the row is full and needs scoring.
rowHasColor( int rowNumber)- return true if there is
color in row of the board. This would be used to detect the
end point of shifting rows down.
copyRow(int rowNumber)- copy row content to the row
below. Used to shift a row down when a full row is scored.
The method affectively over writes the content of the row
below, making the deletion of this row unnecessary, unless
of course you want to go for extra credit and make some
special effect that shows the bricks imploding or something
equally dramatic. :0)
copyAllRows(int rowNumber)- calls the method
copyRow on each row starting with rowNumber and above
(located higher in the well, or at a lower row number)
rowHasSpace( int rowNumber)- returns true if there
is a space in the row of the board. This is used to determine
if the row is full and needs scoring.
A suggested approach uses the following pseudo code copyAllRows:
1.Determine the range of rows to be checked.
2. currentRow - highest row number in range
2. REPEAT for each row within the range starting with max
3. IF rowHasSpace( int rowNumber) is false
4. call copyAllRows(currentRow)
5. current row is incremented (so that when for loop
decrements current, it remains the same
6. min row of range is decremented
7. END IF
8.END REPEAT
Based off of this:
public class TetrisGame
{
private TetrisBrick fallingBrick;
private int rows =2;
private int cols =2;
private int numBrickTypes =7;
private Random randomGen;
private int[][] background;
private int state;
private int score;
public TetrisGame(int rows, int cols)
{
this.rows = rows;
this.cols = cols;
initBoard();
this.randomGen = new Random();
spawnBrick();
copyAllRows(score);
}
public void initBoard()
{
background = new int[rows][cols] ;
for(int row=0; row rows; row++)
{
for(int col=0; col cols; col++)
{
background[row][col]=0;
}
}
}
Could someone please fix my code so that these

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!