This project will bring together everything you've done so far. You will be drawing, getting user input, using loops and if statements, and writing methods. Download the flags and patterns base project and import it into Eclipse, and then modify the FlagDrawer.java and PatternDrawer.java files to complete the parts of the assignment.
Earlier we created lollipop shapes using the UI.draw* methods. In this assignment you will create a specialised flag drawer that allows you to easily generate flags that consist of three equal-size stripes (e: France, Italy, Russia, Germany, etc).
drawThreeColourFlagCore
method to draw a three colour flag consisting of three
vertical equal-width stripes (like the French flag). You
will need to specify the method's parameters as well as
write the body.
drawThreeColourFlagCompletion
method to draw flags where the stripes can be either
horizontal or vertical (so you can draw the Russian flag
as well as the French and Italian). You will need one
more parameter in your method than in the core.
No challenge — move on to the patterns.
There are many patterns made of repetitive elements used in
a wide variety of applications, ranging from board games to
vinyl floor coverings. Complete the methods in the
PatternDrawer
class for drawing a range of
these patterns. Each method requires using loops. The
position and size of the pattern are specified by the three
constants boardLeft
, boardTop
, and
boardSize
. Each method starts by asking the
user for the size - the number of squares along the edge of
the pattern. The loops should use this number!
Grid - the basic pattern for many board games.
You can draw this with lots of squares. Note that it will need two nested loops.
Illusion - a pattern that makes dark circles appear in the intersections when you look at it.
This also requires two nested loops, but each row must have a different number of squares.
Checkers board - the standard board for chess and checkers/draughts
This needs two nested loops but must sometimes draw a filled square and sometimes not.
Concentric circles - a grid of concentric circles
The concentric circles should be separated by one pixel. The larger the cells of the grid (ie, the fewer number of cells) the more circles there will be.