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
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
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 2GZ
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();](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F62544cc1-5b6d-4c69-9690-33e4d8e51c50%2F1433f0e8-f6e4-49c7-9ab4-094a8b3fb086%2Fpfxhune_processed.png&w=3840&q=75)
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");
}](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F62544cc1-5b6d-4c69-9690-33e4d8e51c50%2F1433f0e8-f6e4-49c7-9ab4-094a8b3fb086%2Fs9ilku_processed.png&w=3840&q=75)
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
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Knowledge Booster
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.Recommended textbooks for you
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,