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.
copyRowint 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. :
copyAllRowsint 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:
Determine the range of rows to be checked.
currentRow highest row number in range
REPEAT for each row within the range starting with max
IF rowHasSpace int rowNumber is false
call copyAllRowscurrentRow
current row is incremented so that when for loop
decrements current, it remains the same
min row of range is decremented
END IF
END REPEAT
Based off of this:
public class TetrisGame
private TetrisBrick fallingBrick;
private int rows ;
private int cols ;
private int numBrickTypes ;
private Random randomGen;
private int background;
private int state;
private int score;
public TetrisGameint rows, int cols
this.rows rows;
this.cols cols;
initBoard;
this.randomGen new Random;
spawnBrick;
copyAllRowsscore;
public void initBoard
background new introwscols ;
forint row; row rows; row
forint col; col cols; col
backgroundrowcol;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
