logo CodeStepByStep logo

CafeWall

Write a complete program in a class named CafeWall that draws the following graphical figure onto a DrawingPanel:

Java DrawingPanel close maximize minimize
expected output
 

The overall drawing panel is size 650 x 420. Its background is gray.

Structure your solution and eliminate redundancy using methods. This image has several levels of structure. Black and white squares are used to form rows and pairs of rows are combined to form grids. The output has two free-standing rows plus four grids. You should first write a method to produce a single row. Each row is composed of a certain number of black/white pairs of boxes where each black box has a blue X in it.

The free standing rows in the output have the following properties:

Description (x, y) position number of pairs size of each box
upper-left (0, 0) 4 20
mid-left (50, 70) 5 30

Grids are composed of a series of pairs of rows where in each pair the second row is offset a certain distance in the x direction relative to the first. The output has four grids with the following properties:

Description (x, y) position number of pairs size of each box 2nd row offset
lower-left (10, 150) 4 25 0
lower-middle (250, 200) 3 25 10
lower-right (425, 180) 5 20 10
upper-right (400, 20) 2 35 35

Each pair of lines in the grid should be separated by a certain distance, revealing the gray background underneath. This is referred to as the "mortar" that would appear between layers of brick if you were to build a wall with this pattern. The mortar is essential to the illusion. Your program should use 2 pixels of separation for the mortar.

(You don't need to include any import statements at the top of your program.)

Class: Write a complete Java class.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.