public void consolidate(Block block) // when the dropping block has reached its final location,//this method will consolidate it into the tetris well -- O(block_size)     public void clearRows() // clear any/all rows that are complete and shifts the above tiles down -- O(board_size)     public void reward() // applies the reward as explained in the project description -- O(board_size)     public void penalize() // applies the penalty as explained in the project description -- O(board_size) help me please

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 2GZ
icon
Related questions
Question

public void consolidate(Block block) // when the dropping block has reached its final location,//this method will consolidate it into the tetris well -- O(block_size)

    public void clearRows() // clear any/all rows that are complete and shifts the above tiles down -- O(board_size)

    public void reward() // applies the reward as explained in the project description -- O(board_size)

    public void penalize() // applies the penalty as explained in the project description -- O(board_size)

help me please

class Board
This class represents the two-dimensional well of the tetris (the top-left corner of the board has coordinates 0,0). It is practically a placeholder for the tiles of the blocks that consolidate into the well when the drop stops. However, this well is dynamic and can change its content when certain moves on the block are
made:
public class Board{
public Board (int height, int width)
{
Every time the player scales up the block, the player is rewarded with one row of tiles being removed from the board. The row to be removed is the row with the highest number of consolidated tiles. In case of a tie, remove the lowest row.
Every time the player scales down the block, the player is penalized with an incomplete row inserted to the board. The row to be inserted is a duplicate of the row having the fewest consolidated tiles (in case of a tie, pick the
}
this.board = new DynamicArray<>(height);
for(int y = 0;y<height;y++){
}
DynamicArray<Tile> row = new DynamicArray<>(width);
for(int x = 0; x<width;x++){
row.set(x, null);
}
board.set(y, row);
}
public int getWidth()
{
if(board.size() < 0){
return 0;
}
return board.get(0).size();
Transcribed Image Text:class Board This class represents the two-dimensional well of the tetris (the top-left corner of the board has coordinates 0,0). It is practically a placeholder for the tiles of the blocks that consolidate into the well when the drop stops. However, this well is dynamic and can change its content when certain moves on the block are made: public class Board{ public Board (int height, int width) { Every time the player scales up the block, the player is rewarded with one row of tiles being removed from the board. The row to be removed is the row with the highest number of consolidated tiles. In case of a tie, remove the lowest row. Every time the player scales down the block, the player is penalized with an incomplete row inserted to the board. The row to be inserted is a duplicate of the row having the fewest consolidated tiles (in case of a tie, pick the } this.board = new DynamicArray<>(height); for(int y = 0;y<height;y++){ } DynamicArray<Tile> row = new DynamicArray<>(width); for(int x = 0; x<width;x++){ row.set(x, null); } board.set(y, row); } public int getWidth() { if(board.size() < 0){ return 0; } return board.get(0).size();
}
public int getHeight()
{
}
public void setTile(int y, int x, Tile t)
wwwd
{
if (y >= 0 && y < board.size() && x >= 0 && x < board.get(y).size()) {
board.get(y).set(x, t);
}
return board.size();
}
}
public Tile getTile(int y, int x)
{
if (y >= 0 && y < board.size() && x >= 0 && x < board.get(y).size()) {
return board.get(y).get(x);
} else {
throw new RuntimeException("Invalid indices");
}
Transcribed Image Text:} public int getHeight() { } public void setTile(int y, int x, Tile t) wwwd { if (y >= 0 && y < board.size() && x >= 0 && x < board.get(y).size()) { board.get(y).set(x, t); } return board.size(); } } public Tile getTile(int y, int x) { if (y >= 0 && y < board.size() && x >= 0 && x < board.get(y).size()) { return board.get(y).get(x); } else { throw new RuntimeException("Invalid indices"); }
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

where is the remove function?

 

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Software Systems
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT