Question: class to implement: ______________________________________Block.java____________________ public class Block { private DynamicArray block; // the internal storage of the block data public Block(int y, int









class to implement:
______________________________________Block.java____________________
public class Block
{
private DynamicArray
public Block(int y, int x, int size) // this contructor creates a 2D placeholder of null values; these values will be populated later with calls to setTile() -- O(block_size)
public Block(int y, int x, int size, byte color) // overloaded constuctor that creates a 2D matrix with actual tile objects; no need to call setTile afterwards -- O(block_size)
public int getSize() // returns the length of the side of block -- O(1)
public int getY() // returns the top-left Y-coordinate of the block -- O(1)
public int getX() // returns the top-left X-coordinate of the block -- O(1)
public void setTile(int y, int x, Tile t) // sets the tile at location y,x -- O(1)
public Tile getTile(int y, int x) // gets the tile from location y,x -- O(1)
public void drop() // drops the block by one row -- O(block_size)
public void moveLeft() // moves the block one spot to the left -- O(block_size)
public void moveRight() // moves the block one spot to the right -- O(block_size)
public void rotate() // rotates the block 90 degrees clockwise -- O(block_size)
public void flipVertical() // flips the block vertically -- O(block_size)
public void flipHorizontal() // flips the block horizontally -- O(block_size)
public Block scaleUp() // scales up the block (double size) -- O(block_size)
public Block scaleDown() // scales down the block (half size) -- O(block_size)
}
Basic Procedures You must: You may: Add additional methods and class/instance variables, however they must be private. Import the class Random to generate pseudorandom numbers You may NOT: Make your program part of a package (beware that some IDEs do that by default) Add additional public/protected/package-private methods or variables Use any Java Collections Framework classes anywhere in your program (e.g. ArrayList, LinkedList, etc.) Alter any class/method signatures defined in this document or the template code Have a style (indentation, good variable names, etc.) and pass the provided style checker (see PO). Comment your code well in JavaDoc style and pass the provided JavaDoc checker (see PO). Have code that compiles in your user directory without errors or warnings. For methods that come with a big-O requirement, make sure your implementation meets the requirement. Have code that runs (see detailed commands below). Add any additional import statements (or use the "fully qualified name" to get around adding import statements) Add any additional libraries/packages Create any additional classes or interfaces Use nested classes or lambda expressions
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
