Question: Can someone Translate this code from java to processing? import acm.graphics.*; import acm.program.*; import java.awt.*; public class Pyramid extends GraphicsProgram { private static final int

Can someone Translate this code from java to processing?

import acm.graphics.*; import acm.program.*; import java.awt.*; public class Pyramid extends GraphicsProgram { private static final int BRICK_WIDTH = 40; private static final int BRICK_HEIGHT = 20; private static final int BRICKS_IN_BASE = 12; public void run() { putAllBricks(); } private void putAllBricks() { for( int row = 0; row < BRICKS_IN_BASE; row++ ) { int bricksInRow = BRICKS_IN_BASE - row; for( int brickNum = 0; brickNum < bricksInRow; brickNum++ ) { int x = ( getWidth()/2 ) - (BRICK_WIDTH * bricksInRow) / 2 + brickNum * BRICK_WIDTH; int y = getHeight() - BRICK_HEIGHT * (row+1); GRect brick = new GRect( x , y , BRICK_WIDTH , BRICK_HEIGHT ); add(brick); } } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!