Click to reopen instructions.

Your mission is to draw a flag of the United States. The starting point for your code will be in the drawFlag method which will be called for you with a Graphics2D object and two ints representing the width and height of the drawing area. You should write your code there though you may want to break it into helper methods which you call from drawFlag.

The only methods you need to use from Graphics2D are setColor and fillRect. You can see an example of each in the drawBackground method in the starter code. (Don’t change drawBackground.) You will also almost certainly need to use the drawStar method provided in the starter code.

Your flag must follow the proportions set out in the US code as summarized in this US Flag specification. In addition to being properly proportioned, your flag should be as near as possible to but no larger than 90% of the size of the largest properly-proportioned flag that could fit in the drawing area. The flag should be centered horizontally and vertically in the drawing area and your code should work correctly regardless of the aspect ration of the drawing area.

If you finish early: If you get your flag working, as an extra challenge, modify the makeStar method to take an argument of the number of points and draw a start with that many points rather than always drawing a five-pointed star.

Put definitions here.

Revisions:

Flag

Compilation errors