Question: Starter code: In this assignment, you will write a class StarsAndStripes that can draw a generalized United States flag. The following image represents some of

In this assignment, you will write a class StarsAndStripes that can draw

  a generalized United States flag. The following image represents some of the 

Starter code:



kinds of flags that your program will be able to draw: 0,0 Graphics window Write the following method which draws a US flag representation 

In this assignment, you will write a class StarsAndStripes that can draw a generalized United States flag. The following image represents some of the kinds of flags that your program will be able to draw: 0,0 Graphics window Write the following method which draws a US flag representation with the given number of stars and stripes starting at the given (x, y) coordinate (upper left corner in Java's coordinate system) and of the given width and height. Notice that a flag may fill only part of the window like the four flags drawn above! public static void drawFlag (int stars, int stripes, java.awt.Graphics g, int x, int y, int width, int height) Assume stars, stripes, width, and height are at least one. You should only call fill Rect, drawLine, and setColor methods on the java.awt.Graphics object. Color.red, Color.white, Color.blue are the only colors allowed. To reduce confusion and differences in calculation, you should only perform math with int, not with double. In addition, another method is specified on the back of this worksheet. Your drawFlag method should follow the following procedure so that it can be properly tested: First, draw a filled white rectangle (base) of the given x, y, width, and height. Second, draw filled red rectangles (red stripes) across the width of the base. The first rectangle should begin in the base's upper left. Each red stripe height (except possibly the last one) should be (height divided by stripes) rounded down. Then, skip down according to the red stripe height which will

Step by Step Solution

3.40 Rating (150 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

import tkinter as tk class StarsAndStripes staticmethod def drawFlagstars stripes canvas x y width height Initialize the canvas canvascreaterectanglex ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!