Question: When the program starts, there should be a small circle on the canvas (the example shows a white circle on a black canvas, but the
When the program starts, there should be a small circle on the canvas (the example shows a white circle on a black canvas, but the colors are irrelevant: use what you like) When the user presses a number key lie through the diameter of the circle should multiplica tively increase by the value of the number pressed For example, if the user presses the "3" key. the circle should triple in size of the user presses a key that is not a digit your program will crash that is ok, you don't need to handle this case) When the user click the mouse, the circle should be moved to the location of the mouse and reset to its original size Figure 1 Small circle starts in the middle etti, triples in size when3" is pressed (middel and then moves and resets to original site when mouse clicked, then doubles in size when '2' is pressed Here's 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- cter of the circle (an integer, and the digit key that was pressed on the keyboard la 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 cocel, 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 to your function for steps working you can add the interactive part of your program Make sure to use a good Model ViewController digo and decide what your global variables will be then add your setup.dra tousecandy Peedo functions Call your calculate func on in the montplace when you need to change of the circle hint this will only in Press
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
