Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The quilt will be composed of two separate tile. The last method will use loops to draw an entire quilt in a checkerboard formation: public

The quilt will be composed of two separate tile. The last method will use loops to draw an entire quilt in a checkerboard formation:
public static void drawQuilt(Graphics 9, int x, int y, int tilesize,
int rows, int columns)
g is the Graphics object that will draw shapes on your behalf
x and y represent the upper left corner of the entire quilt
tileSize represents the width/height of a single tile of the quilt
rows and columns represent the number of rows and columns of tiles in the quilt
The method should use a nested loop and alternate between your drawTileA and drawTileB methods to
achieve a checkerboard. The tester expects that your inner loop draws a row and the outer loop repeats the
inner loop to draw multiple rows.
The tester will try drawing multiple copies of your quilt at different locations in the drawing window with
different tileSize values and different rows and columns.
Java's Graphics library does not contain a fillTriangle method. For convenience, I have included one for you in
the starter code for the assignment:
public static void filltriangle(Graphics 9, Color c, int x1, int y1,
int x2, int y2, int x3, int y3{
int []xs={x1,x2,x3};
int [] ys ={y1,y2,y3};
g.setColor (c);
g.fillpolygon(xs, ys,3);
}
Since this is a custom method defined by me, it is called a little differently than the built-in graphics methods.
The built-in methods are called using the syntax g.methodName(...);
Example: g.filloval(x+ size /4, y + size /4, size /2, size /2);
The fillTriangle method is called using the syntax fillTriangle(g,...x+y+x+y+ size, x+ size, y+ size ??2
designs arranged in a checkerboard formation. Below is an example quilt:
Start with the ColorfulQuilt class from Canvas. You will be writing three methods that together will create
a quilt formation such as the one displayed above. The first method will draw a single copy of your first tile
design:
public static void drawTileA(Graphics 9, int x, int y, int size)
g is the Graphics object that will draw shapes on your behalf.
,x and y represent the upper left corner of the tile. All coordinate calculations should use x,y as a
starting point as shown in class so that tiles can be drawn at any location in the drawing window.
size represents the width/height of the square tile.
The CYAN/BLACK/DARK_GRAY tile above is an example tile drawn by this method. The tile should be square
and meet the following minimum requirements:
At least 3 colors
At least 3 triangles
At least 1 circle
At least 1 rectangle
The second method will draw a single copy of your second tile design:
public static void drawTileB(Graphics g, int x, int y, int size)
The GRAY/RED/BLACK tile above is an example tile drawn by this method. The tile should be square and has
the same minimum requirements as the drawTileA method (at least 3 colors, 3 triangles, 1 circle, 1
rectangle). However, Tile B has the following additional requirements:
The number of shapes should be different from Tile A. For example, my Tile A design above has 6
shapes (1 black border rectangle, 4 cyan triangles, 1 dark gray circle) and my Tile B design above has 9
shapes (1 dark gray background rectangle, 4 red circles, 4 light gray triangles).
The number or shade of the colors should differ. For example, Tile A above has 3 colors (CYAN,
DARK_GRAY, BLACK) and Tile B has 3 colors (LIGHT_GRAY, DARK_GRAY, RED). This follows the rule
since the two tiles differ in their color shades. It is also okay if colors are reused but one tile has more
colors than the other.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago