Answered step by step
Verified Expert Solution
Question
1 Approved Answer
class Block This class represents a two - dimensional tetris piece dropping into the tetris well. Figure 1 depicts some examples of pieces. The block
class Block
This class represents a twodimensional tetris piece dropping into the tetris well. Figure depicts some examples of
pieces. The block is practically a squaresize placeholder for the Tile objects. But not all the spots are necessarily
occupied. When the block is generated, we randomly pick the spots that will be filled in with tiles. All the tiles of a block
must have the same color. Lastly, the block is dynamic which means that while its dropping into the well it can transform
in the following ways:
It can move left or right one spot at a time
It can flip vertically or horizontally
It can rotate clockwise degrees at a time
It can scale up double in size or scale down shrink in half, but cant become smaller than x public class Block
private DynamicArray block; the internal storage of the block data
public Blockint y int x int size this contructor creates a D placeholder of null values; these values will be populated later with calls to setTile Oblocksize
public Blockint y int x int size, byte color overloaded constuctor that creates a D matrix with actual tile objects; no need to call setTile afterwards Oblocksize
public int getSize returns the length of the side of block O
public int getY returns the topleft Ycoordinate of the block O
public int getX returns the topleft Xcoordinate of the block O
public void setTileint y int x Tile t sets the tile at location yx O
public Tile getTileint y int x gets the tile from location yx O
public void drop drops the block by one row Oblocksize
public void moveLeft moves the block one spot to the left Oblocksize
public void moveRight moves the block one spot to the right Oblocksize
public void rotate rotates the block degrees clockwise Oblocksize
public void flipVertical flips the block vertically Oblocksize
public void flipHorizontal flips the block horizontally Oblocksize
public Block scaleUp scales up the block double size Oblocksize
public Block scaleDown scales down the block half size Oblocksize
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