Due Sunday 19-Sep, at 10:00pm
While you may submit to Gradescope as often as you like for this assignment, some questions are not autograded, so you will be responsible for testing your code and making sure it meets the problem requirements. As stated in the style guide, you do not have to write test cases for interactive, random, graphics, data initialization or event functions. Instead, you should test by visually inspecting your code’s behavior as you complete steps of each problem, where reasonably possible. This will make debugging your code much easier.
Do not use lists, sets, dictionaries, try/except, classes, or recursion this week. The autograder (or a manual CA review later) will reject your submission entirely if you do.
Like in the previous assignment, we will be grading your code based on whether it follows the 15-112 style guide. We may deduct up to 10 points from your overall grade for style errors. We highly recommend that you try to write clean code with good style all along, rather than fixing your style issues at the end. Good style helps you code faster and with fewer bugs. It is totally worth it. In any case, style grading already started, so please use good style from now on!
Write the function drawUnitedStatesFlag which draws the US flag in the provided dimensions. You can assume that the height:width ratio will be 10:19, as is the case with the actual US flag.
You can find much useful information about the flag’s dimensions on Wikipedia:
https://en.wikipedia.org/wiki/Flag_of_the_United_States, but we do not expect you to match the actual US flag design perfectly; you should instead seek to create a reasonable approximation of the flag. However, your flag must meet the following requirements:
The flag should start from the upper left-hand corner of the window.
The flag should have the correct number of stripes, alternating red and white in the correct order.
The blue field in the upper left corner should cover exactly seven stripes and have a reasonably correct width.
The flag should have the correct number of stars in the correct configuration, with the star size and spacing reasonably close to the actual flag.
The colors should be the correct shades of red and blue. (Check Wikipedia)
For an example of what reasonable flags might look like, here is an example:
In this example, data
represents a list of 10 items: 2 bananas,
3 oranges, 4 apples, and 1 pineapple. In other words, a 0.2 fraction of the
items in data
are bananas, 0.3 oranges, 0.4 apples and 0.1
pineapple.
data
. Each tick should be labeled with the corresponding word in a vertical orientation.drawNiceRobot(canvas, width, height)
that (you guessed it!) draws a nice robot!
This is not meant to be very difficult. We just want to see some really cool robots while grading your homework. Your function must make a drawing using the 112 graphics library that meets the following criteria:
cmu_graphics, string, math
. Have fun!