Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

   

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 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

Step: 1

import tkinter as tk class StarsAndStripes staticmethod def drawFlagstars stripes canvas x y width height Initialize the canvas canvascreaterectanglex ... 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

Java An Introduction To Problem Solving And Programming

Authors: Walter Savitch

8th Edition

0134462033, 978-0134462035

More Books

Students also viewed these Programming questions

Question

Calculate the missing values for the promissory notes described

Answered: 1 week ago