Question: Figure 1 : Small circle starts in the middle ( left ) ; triples in size when 3 is pressed ( middle ) and then

Figure 1: Small circle starts in the middle (left); triples in size when 3 is pressed (middle) and then moves and resets to original size when mouse is clicked, then doubles in size when 2 is pressed.
Heres a description of how to go about your work Step 1
Define a function called calculate_size(). This function should have two input parameters: the old diam- eter of the circle (an integer), and the digit key that was pressed on the keyboard (a string). The function should first convert the digit from a string to an integer (hint: use the int() function to do this) and then multiply it with the old diameter and return the result. This isnt a lot of work for the function to do (in fact, it might just be 1 line of code), but the point is to practice using parameters and return values. Importantly, the function should not use global variables in any way.
Step 2
Once you are sure your function from step 1 is working, you can add the interactive parts of your program. Make sure to use a good Model-View-Controller design and decide what your global variables will be, then add your setup(), draw(), mouseClicked() and keyPressed() functions. Call your calculate_size() func- tion in the right place when you need to change the size of the circle (hint: this will only be in keyPressed()).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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!