//Thomas Burlingame //CSE 142 //TA: Simone Schaffer //Description: This program produces rows and grids //of varying size in the drawing panel at specified areas. import java.awt.*; public class CafeWall{ public static final int MORTAR = 2; public static void main(String[] args){ DrawingPanel panel = new DrawingPanel(650, 400); panel.setBackground(Color.GRAY); Graphics g = panel.getGraphics(); drawRow(g, 0, 0, 4, 20); drawRow(g, 50, 70, 5, 30); drawGrid(g, 10, 150, 4, 25, 8, 0); drawGrid(g, 250, 200, 3, 25, 6, 10); drawGrid(g, 425, 180, 5, 20, 4, 10); } public static void drawRow(Graphics g, int x, int y, int pairs, int size){ for (int j = 0; j < pairs; j++){ g.setColor(Color.BLACK); g.fillRect(x+(j*size*2), y, size, size); g.setColor(Color.WHITE); g.fillRect(x+size+(j*size*2), y, size, size); g.setColor(Color.BLUE); g.drawLine(x+(j*size*2), y, x+size+(j*size*2), y+size); g.drawLine(x+size+(j*size*2), y, x+(j*size*2), y+size); } } public static void drawGrid(Graphics g, int x, int y, int pairs, int size, int height, int offset){ drawRow(g, x, y, pairs, size); for (int i = 1; i <= (height/2)-2; i++){ drawRow(g, x+offset, y+(size*i)+(MORTAR*i), pairs, size); drawRow(g, x, y+(size*2*i)+(MORTAR*i*2), pairs, size); } } }