Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Need this coded in PROCESSING (PYTHON) PLEASE. Question 3 (9 points): Purpose: Practice with concitionals practice with variables and good program design Degree of Difficulty:
Need this coded in PROCESSING (PYTHON) PLEASE.
Question 3 (9 points): Purpose: Practice with concitionals practice with variables and good program design Degree of Difficulty: Moderate For this problem, we have 3 bails of different weights. Your job is to write a program that allows the user to place the balls on either side of a scale and reports which side of the scale is heavier The left sec le is heavier Figure 2: An example with all balls currently on the left-hand scale Here is a description of how your program should look Use a 400x300 canvas size .Colour half of the screen white and the other half black. Each half of the screen represents one side .Display 3 balls on the cavas Each ball has a different weight lkg. 2kg and 3kg) Each bal should be Display at all times on the canvas a message indicating whether thescale is balanced, or if not, which of a scale a different colour, and heavier balis should be bigger side is heavier, based on the position of the balls Here is a description of how your program should behave Initially the balls can be anywhere on the screen in the example above, they are al on the left-hand side of the scale When the user presses T. The lkg ball should be moved to the location of the mouse .When the user presses 2 The 2kg ball should be moved to the location of the mouse. . When the user presses 3: The 3kg ball should be moved to the location of the mouse Of course, the message concerning which side of the scale is heavier should be kept up to date as the balls mave Here are some suggestions for how to design your program, especially with regard to the Model-View Controller design pattem .You will want to use at least 6 global variables in your program: these are the current x and y coor- dinates for each of the three balls. You may wish to use another 3 global variabies for the weight of each ball as well although since the weights do not change this is not strictly necessary. .You will likely want your dra) function to take care of the following tasks - Drawing the 2 sides of the scale -Drawing the 3 balls at their current positions - Determining the correct message to display based on the positions and weights of the 3bals You will Lkely want your keyPressed) function to take care of changing the positions of the balls by simply changing the global variables (ie the modell that represent each ball's position What To Hand In: Your Processing sketch folder Inaned a5q3 compressed as a zip file (.zipl This folder should contain your Processing program as a -pyde fle with the same name as the felder lie a5e3.pyde) and a aketch.properties project file Evaluation: .O marks for submitting nothing and/or files that cannot be opened .-1 mark for Lack of identification in the solution 2 marks for correctly displaying balls and the background 2 marks for correctly moving the balls on a keypress e3 marks for using conditional statements to determine which scale is heavier and displaying the cor rect message 1 mark for documenting code using comments and docstrings 1 mark for good Model-View-Controller style design Question 3 (9 points): Purpose: Practice with concitionals practice with variables and good program design Degree of Difficulty: Moderate For this problem, we have 3 bails of different weights. Your job is to write a program that allows the user to place the balls on either side of a scale and reports which side of the scale is heavier The left sec le is heavier Figure 2: An example with all balls currently on the left-hand scale Here is a description of how your program should look Use a 400x300 canvas size .Colour half of the screen white and the other half black. Each half of the screen represents one side .Display 3 balls on the cavas Each ball has a different weight lkg. 2kg and 3kg) Each bal should be Display at all times on the canvas a message indicating whether thescale is balanced, or if not, which of a scale a different colour, and heavier balis should be bigger side is heavier, based on the position of the balls Here is a description of how your program should behave Initially the balls can be anywhere on the screen in the example above, they are al on the left-hand side of the scale When the user presses T. The lkg ball should be moved to the location of the mouse .When the user presses 2 The 2kg ball should be moved to the location of the mouse. . When the user presses 3: The 3kg ball should be moved to the location of the mouse Of course, the message concerning which side of the scale is heavier should be kept up to date as the balls mave Here are some suggestions for how to design your program, especially with regard to the Model-View Controller design pattem .You will want to use at least 6 global variables in your program: these are the current x and y coor- dinates for each of the three balls. You may wish to use another 3 global variabies for the weight of each ball as well although since the weights do not change this is not strictly necessary. .You will likely want your dra) function to take care of the following tasks - Drawing the 2 sides of the scale -Drawing the 3 balls at their current positions - Determining the correct message to display based on the positions and weights of the 3bals You will Lkely want your keyPressed) function to take care of changing the positions of the balls by simply changing the global variables (ie the modell that represent each ball's position What To Hand In: Your Processing sketch folder Inaned a5q3 compressed as a zip file (.zipl This folder should contain your Processing program as a -pyde fle with the same name as the felder lie a5e3.pyde) and a aketch.properties project file Evaluation: .O marks for submitting nothing and/or files that cannot be opened .-1 mark for Lack of identification in the solution 2 marks for correctly displaying balls and the background 2 marks for correctly moving the balls on a keypress e3 marks for using conditional statements to determine which scale is heavier and displaying the cor rect message 1 mark for documenting code using comments and docstrings 1 mark for good Model-View-Controller style designStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started