To fill in the board square covered by a piece, it
would be helpful to have a method similar to the one above that copies
the non-zero entries from the given array into the corresponding board
squares.

I need to implement this now, but I have the following questions:

where do I put the contents array? I don't see a board array in the program

do
i need to put the contents array inside the board once it was laid down
or once it appears? and how do i know a piece was laid down? what if
statement should i use for that?

Can you explain how this works? The code is lacking comments, and (for me) it is hard to understand how it works. I do know this is tetris though. Is the bold text the assignment criteria you have to follow?

Study the provided code to get a feel for what it does. Some
of the graphics details (for example, how graphics components are
created, added to containers, and painted) haven't been covered in
CSE131, but go ahead and read through the files Tetris.java,Grid.java, Board.java, Piece.java, andPieceFactory.java to understand the way the implementation
is organized. Notice that the Tetris class provides some static
methods for getting references to the board and the tetris game
itself so that other objects can call methods on them, for example
to check if a board position would be legal, or to add points to
the score.

The class Grid is the parent of both the Board and Piece classes.
Study its implementation. Notice that a Grid object is created by
passing it an array of rows, where each row is an array of integers
representing the squares in the columns of that row. If an array
entry is 0, the corresponding square is considered to be empty.
Look at the paint method to see how a grid paints itself based on
its array.

Add a method to the Grid class that takes in a row number
as a parameter and returns true exactly when the given row is
full (has no zero entries). This will be useful for determining
when to remove a row from the board.

Similarly, add a method to the Grid class that returns true
when a given row is entirely empty. This will be useful for
determining when the game is over. (Because the game continues
as long as the top row of the board is empty.)

The Board class extends Grid. It will be helpful to add the
following methods:

Write a method in the Board class that takes a row and
column index and a two-dimensional array as parameters, and
checks to see that the non-zero entries of the given array
correspond to empty positions on the grid, assuming that the
given array's upper left were positioned at the given row and
column. You'll use this to determine if a piece can move into
a given position.

To fill in the board square covered by a piece, it would be
helpful to have a method similar to the one above that copies
the non-zero entries from the given array into the corresponding
board squares.

Finally, when it's necessary to remove a row, it would be
nice to have a method on the board that would take that row
out, move all the others down, and then replace the top row
with an empty one. For effect, you may want to first clear
the row being removed, sleep one second, and then bump down
the other rows. Remember that since the grid is represented
as an array of rows, it is not necessary to copy all the values
in the arrays. Just move the rows themselves.

The Piece class also extends Grid. Notice that its currentX
(column) position is represented as an int, but its currentY (row)
position is represented as a double. This is so you can drop the
piece gradually, probably 1/5 of a square at a time. To determine
the next whole row number, the method Math.ceil may help
you.

In the Piece class, you'll want methods for moving the
piece down, moving it left and right by one column, and for
rotating the piece clockwise and counterclockwise 90 degrees.
(You want these methods to be synchronized so that two
modifications of the piece aren't attempted concurrently.)
When a piece is rotated, the array changes shape (somewhat
similar, but not exactly like, the transpose algorithm we did
in class). Note: Each time you move a piece, call its
updateLocation method so that it gets painted properly on the
board. Similarly, each time you change the shape of a piece,
call its updateSize method. You should only move or rotate a
piece if it would be legal to do so. (The methods of the Board
will be helpful for determining legality of a board position.)

You'll need to write a method that is responsible for making
the piece fall from the top of the board until it's supposed to
stop, at which time it should fill in the board as appropriate.
Call the static sleep method in the Tetris class to
control the animation speed. Remember, though, that when the
space bar is pressed, the piece should fall without delay.

obviously homework.... The questionsuggests you already have a function that pretty much does what it is you're supposed to do, you just have to make the changes you're told to make and write a new function to to just that.

You don't see the the board array? it's the first chunk of code you posted.

if this really is homework, ask your instructor these same exact questions, that's what you're paying him for.

Oh I see what you mean, after thinking about how I would make a tetris clone.

I suppose I would keep the position of the shape that is currently dropping down, and not write the shape array into the content array until the shape hits bottom and becomes part of the unmoving blocks.

What would the condition be then? And how do you access the shape variable from the Board class? Earlier, for Piece, I simpy wrote shapes = a (a = int[][]array), but the method call was currentPiece.moveDown() (currentPiece is an instance of Piece). If the method call was simpy method(), how would I assign the shape variable of the Board class a value (both Piece and Board inherit shapes attribute from the parent class).

I guess I am confused again. When you say "putting a piece inside the board", do you mean when a new pieces comes into the view at the top? Or do you mean when the piece finally settles down and becomes a part of the board landscape?

If you mean writing the contents of a piece array into the board array, I think it should happen only when the pieces settles down, and not when it is still moving. So I don't think it belongs in the moveLeft method, unless I am misunderstanding you again.

Ok, now I see what you mean. The array you are looking for is in the Grid class. You don't see it in the Board class because Grid has it. Is the Grid class available to you? You will have to see which methods of the Grid class allows you to change the array.

Ok, I have some trouble. I get array out of bound exception if I go all the way down, because my method legalDown checks below the grid. So I could only fix it partially by making it stop at 31, then it froze so I fixed it by making it stop at 28 and then some pieces go below 28 after I rotate them. Now, I don't know what to do... Help! And how do I know that a piece landed? Like I fill the array at the end, but it doesn't seem to work that well at certain times...

If, after a rotation, a piece goes underground, then don't allow the rotation to happen. You can either first check that the surrounding area is clear before rotating, or you can rotate and undo if it goes underground.

A shape is considered landed if it overlaps with the board after a drop or a movedown.