So I'm relatively new to Java, and I've been working with Eclipse. The main part of this is the last three lines, I want to have the object myBrick appear multiple times. If I run this, it only appears in the second location (the last line). Is it possible?
import acm.graphics.*;
import acm.program.*;
import java.awt.*;
public class Pyramid extends GraphicsProgram {
/** Width of each brick in pixels */
private static final int BRICK_WIDTH = 30;
/** Height of each brick in pixels */
private static final int BRICK_HEIGHT = 12;
/** Number of bricks in the base of the pyramid */
private static final int BRICKS_IN_BASE = 14;
public void run() {
double windowWidth = 756;
double windowHeight = 494;
int numberOfBricks = (BRICKS_IN_BASE*(BRICKS_IN_BASE+1))/2;
double emptySpace = windowWidth - (BRICK_WIDTH*BRICKS_IN_BASE);
int cushion = (int)emptySpace/2;
GRect myBrick = new GRect(BRICK_WIDTH, BRICK_HEIGHT);
add(myBrick, cushion, (windowHeight-BRICK_HEIGHT));
add(myBrick, (cushion+BRICK_WIDTH), (windowHeight-BRICK_HEIGHT));
}
}