Java coding for making bricks