Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Can someone please write the java syntax for full implementation of the java code for the methods makeMove, and validateMove in class Tetrisgame and moveDown,
Can someone please write the java syntax for full implementation of the java code for the methods makeMove, and validateMove in class Tetrisgame and moveDown, moveUp method in class TetrisBrick based off description and uml.
TetrisGame methods:
The makeMove Takes a char move code as argument. The move code should indicate which direction the falling brick
should move; down. The only move you need to account for is down. makeMove should
call the method validateMove after the move is made to
make sure it was valid. The move should be reversed if validateMove returns false.It should reverse the last
move when brick hits the bottom and tries to move into the
border of the well makeMove has no return value.
validateMove checks the move just made to make sure
the brick is in bounds, returning true if all segments of the
brick are valid and false if any segment is not valid.It simply has to check that the brick is not below the
bottom of the well. As shown in the UML, this methods has
not arguments.
TetrisBrick methods:
moveDown This method adjusts the row element of
each segment to move the whole brick down one row of the
board. No arguments, no return values.
moveUp This method adjusts the row element of each
segment to move the whole brick up one row of the board.
This is used only when the move down method is invalid. It is not an allowed move for the player to select and as such will
not be associated with a key for the user to trigger.
code so far:
import java.util.;
public class TetrisGame
private TetrisBrick fallingBrick;
private int rows ;
private int cols ;
private int numBrickTypes ;
private Random randGen;
public TetrisGameint rows, int cols
this.rows rows;
this.cols cols;
this.fallingBrick new TetrisBrick;
this.randGen new Random;
spawnBrick;
private void spawnBrick
int centerCol this.cols;
randGen new Random;
int brickType randGen.nextIntnumBrickTypes;
switchbrickType
case :
fallingBrick new ElBrickcenterCol;
break;
case :
fallingBrick new EssBrickcenterCol;
break;
case :
fallingBrick new JayBrickcenterCol;
break;
case :
fallingBrick new ZeeBrickcenterCol;
break;
case :
fallingBrick new StackBrickcenterCol;
break;
case :
fallingBrick new LongBrickcenterCol;
break;
case :
fallingBrick new SquareBrickcenterCol;
break;
public void makeMovechar moveCode
private boolean validateMove
return false;
public int getFallingBrickColor
return fallingBrick.getColorNumber;
public int getNumberSegs
return fallingBrick.numSegments;
public int getSegRowint segNumber
return fallingBrick.positionsegNumber;
public int getSegColint segNumber
return fallingBrick.positionsegNumber;
public int getRows
return rows;
public int getCols
return cols;
import java.awt.;
public class TetrisBrick
protected int numSegments ;
protected int position new int numSegments;
protected Color color;
protected int colorNum;
public void TetrisBrick
public void moveDown
public void moveUp
public int getColorNumber
return colorNum;
public void initPositionint centercolumn
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started