CafeWall.java - Xinbei Du CSE 142 TA Judith Kim Assignment#3 This program will draw a black and white cafewall The cafewall inculdes two standing rows

CafeWall.java - Xinbei Du CSE 142 TA Judith Kim...

This preview shows page 1 out of 1 page.

// Xinbei Du // 10/18/16 // CSE 142 // TA: Judith Kim // Assignment #3 // // This program will draw a black and white cafewall // The cafewall inculdes two standing rows and four grids // with different sizes and pairs of black and white boxes import java.awt.*; public class CafeWall { public static final int mortar = 1; public static void main(String[] args) { DrawingPanel p = new DrawingPanel (650, 400); p.setBackground(Color.GRAY); Graphics g = p.getGraphics(); twoRows(g, 0, 0, 20, 4); twoRows(g, 50, 70, 30, 5); fourGrids(g, 10, 150, 25, 4, 8, 0); fourGrids(g, 250, 200, 25, 3, 6, 10); fourGrids(g, 425, 180, 20, 5, 10, 10); fourGrids(g, 400, 20, 35, 2, 4, 35); } // This method draws two single rows that have different sizes and pairs public static void twoRows(Graphics g, int x, int y, int size, int pairs) { for (int i = 1; i <= pairs; i++) { g.setColor(Color.BLACK); g.fillRect(x+2*size*(i-1), y, size, size); g.setColor(Color.WHITE); g.fillRect(x+size*(2*i-1), y, size, size);
Image of page 1

You've reached the end of your free preview.

Want to read the whole page?

  • Winter '07
  • martystepp
  • Computer Programming, Harshad number, Harry Connick, Jr., int size, Judith Kim, final int mortar, int pairs

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture