Starter code: In this assignment, you will write a class StarsAndStripes that can draw a generalized United
Fantastic news! We've Found the answer you've been seeking!
Question:
Starter code:
Transcribed Image Text:
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 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
Expert Answer:
Answer rating: 100% (QA)
import tkinter as tk class StarsAndStripes staticmethod def drawFlagstars stripes canvas x y width height Initialize the canvas canvascreaterectanglex ... View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
Demand function for a firm is given as P-100e, if the firm's average cost (AC) is AC 5+50, determine the firm's maximum profit. (5marks).
-
Mr Ha is interested in setting up a coffee shop in Canberra, Australia. After consulting with his brother who owns a caf in other town of the territory, he has decided to commence the business in...
-
Ticket to Ride is a popular board game that involves connecting cities in a given railroad network. In this assignment you will prototype some potential approaches for creating an AI player for this...
-
AutoSave Off File C30 PivotTable Recommended Table Pivot Tables 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 A Enter Home Insert Tables H Price Par Value B X Coupon Rate Payment Frequency...
-
The shaft is supported by a smooth thrust bearing at A and a smooth journal bearing at B. Draw the shear and moment diagrams for theshaft. 500 N 300 N/m IB -1.5m -1.5 m-
-
An artist experimenting with clay to create pottery with a special texture has been experiencing difficulty with these special pieces. About 40% break in the kiln during firing. Hoping to solve this...
-
The pendulum on a grandfather clock has a period of 2.00 s. If the clock is not wound, the pendulums amplitude begins to decay at a rate of 0.53% each pendulum period. a. What is the time constant of...
-
Fredonia Repair Inc. was started on May 1. A summary of May transactions is presented below. 1. Stockholders invested $10,000 cash in the business in exchange for common stock. 2. Purchased equipment...
-
Problem 5: Suppose that the S&P 500 index has an expected return of 7% and a standard deviation of returns of 20%. The risk-free rate is 2%. a) What is the slope of the Capital Allocation Line (CAL)?...
-
Variable and fixed costs, profitability of order, opportunity cost Healthy Hearth specializes in lunches for health-conscious people. The company produces a small selection of lunch offerings each...
-
A partial list of the account balances on November 1,2020, for the Don Manufacturing Company were Materials Inventory (Direct and Indirect) $73,000; Work in Process, $70,000; and Finished Goods,...
-
Begin this process in advance of the start date by communicating over email. It will help make day one of the job much less overwhelming, as employees will have a better sense of what they can...
-
For a research project on geese, 51 geese were tagged and released. Later, researchers counted 460 geese, of which 34 had tags. To the nearest whole number, what is the best estimate for the goose...
-
Conduct a risk analysis and management process for the Training of Entrepreneurship with the mentor's strategy, especially with the current prevailing COVID-19 conditions. The output should be in the...
-
Synthesis Labs had $7,000,000 in total supplier purchases and an average accounts payable of $800,000. What is Synthesis Labs' accounts payable turnover ratio? What does this mean?
-
A triangular prism has base edges 4cm,5cm, and 8cm long. Its lateral area is 408cm^(2). What is the height of the prism?
-
A company purchases $10,000 in inventory that will be paid for in 60 days. Which of the following best describes the journal entry to record this transaction? Debit cash $10,000; credit inventory...
-
Chicago Company sold merchandise to a customer for $1,500 cash in a state with a 6% sales tax rate. The total amount of cash collected from the customer was $558. $600. $642. $636. Nevada Company...
-
In the previous chapter, Self-Test Question 16 described a class Person to represent a person. The class has instance variables for a persons name, which is a string, and an integer age. These...
-
Write a class ContactInfo to store contact information for a person. It should have attributes for a persons name, business phone, home phone, cell phone, e-mail address, and home address. It should...
-
Add a method bubbleSort to the class ArraySorter, as given in Listing 7.10, that performs a bubble sort of an array. The bubble sort algorithm examines all adjacent pairs of elements in the array...
-
Go to https://www.youtube.com/watch?v=Fp9m4GNwGng to view a brief video on the Brazilian Jet manufacturer Embraer and their use of Critical Chain Project Management for maintenance services. How has...
-
It is sometimes argued that state revenue generated by lotteries is different from tax revenue because people choose to buy lottery tickets. Compare three state revenue sources cigarette excise...
-
Suppose that the demand for personalized license plates and the marginal cost of production in a state is as shown in Figure 16.1. If all the profits go to the government and the state wants to...
Study smarter with the SolutionInn App