Please use Python in Processing to solve this
and if possible also post the screenshot of the
code in Processing. Please answer it as soon as possibe already posted this yesterday but code was incorrect.
Question 2 ( 9 points): Purpose: Practice with getting data from functions. Some basic numerical problem-solving Degree of Difficulty: Moderate Minecraft is an open-world video game based on placing and interacting with 3D textured blocks. If you are not familiar with the game, each player has a personal inventory which can hold a limited number of blocks and items. Specific blocks and items can be combined on a crafting table to form new items. For example, three wheats arranged in a horizontal line on a crafting table gives the player one loaf of bread. These combinations are known as crafting recipes and the game has hundreds of them. This question deals with the recipe for making a cake. One cake requires 1 egg. 2 sugars, 3 wheats and 3 buckets of milk. Your job is to build a program to help the player determine how many cakes they can make based on the number of ingredients that they have. Figure 2: A screenshot from Minecraft showing a crafting table showing the recipe for making a cake. Your program won't make this picture, this is just showing you the rules for making a cakel Most items in the player's inventory - such as sugar and wheat - can be stoched in groups of 64 . This allows the player to store 64 of the same item in one inventory slot. Some items - such as eggs - can only be stacked in groups of 16. Finally, items like buckets of milk cannot be stacked, each bucket of milk occupies one inventory slot. Here is a description of WHAT your program should do when it's finished: - Pressing the "e" key/"r" key increases/decreases the number of STACKS of eggs available by one. - Pressing the "s' key/"d' key increases/decreases the number of STACKS of sugar available by one. - Pressing the " \( w \) " key/ \( q \) " key increases/decreases the number of STACKS of wheat available by one. - Pressing the " \( \mathrm{m} \) " key/" \( \mathrm{n} \) " key increases/decreases the number of individual buckets of milk available by one. - Display the current number of eggs, the current number of sugar, the current number of wheat and the current number of milk available. - Display the number of cakes the player could possibly make given the amount of raw ingredients. Some examples: - If you have 1 stack of eggs (16 eggs total), 1 stack of sugar (64 sugars total). 1 stack of wheat ( 64 wheats total) and 3 buckets of milk you can only make 1 complete cake before you run out of milk - If you have 2 stacks of eggs (32 eggs total). 3 stacks of sugar (192 sugars totab), 2 stacks of wheat (128 wheats totab and 150 buckets of milk. you can make 32 complete cakes before you run out of eggs.
Now, here is a description of HOW you should write the program: Start by understanding the problem: - Read the question carefully, and identify the things you are sure about, and the things you are unsure about. If you have any questions, make sure to ask an instructor, a TA or post on the class discussion forums Next, prepare some test cases. A test case is a set of input values for the program where you will be able to compare the result your program gives you with the result that you are expecting (because you calculated it by hand). Prepare three examples different from those on the previous page to demonstrate that your program works. For this problem, you will need to hand in your testing in a separate document. This can be a simple text document if you like, where for each of the 3 test cases, you state something like: "I used A stacks of eggs, \( B \) stacks of sugar, \( C \) stacks of wheat and \( D \) buckets of milk. This should yield a result of \( \mathrm{X} \) total cakes. My program gave a result of \( Y \) total cakes: Of course, if your program is working. \( X \) and \( Y \) will be the same, but the whole point of testing is not to assume that this will be the case in advance! Next, start writing your code by creating a function called make_cakes (). This function should accept four parameters, the number of stacks of eggs, the number of stacks of sugar, the number of stacks of wheat and the number of buckets of milk. It should follow these steps: - Calculate how many eggs, sugars, wheats and milks there are based on the number of stacks of each - Calculate how many complete cakes can be made based on the recipe for cakes provided above - Return the number of complete cakes you can make Once this function is done, you can (and should) test it before adding any further components of the program. You can do this by just writing a few function calls with hard-coded, literal arguments and just printing out the return value. You don't need to hand in this intermediate testing. but it's a good habit to get into and will save you time in the long run! Finally, add the interactive components to the program. This will include handling the keyboard input to modify the amount of raw ingredients available as well as displaying the program's output to the Processing canvas. Note that you should be displaying the total number of ingredients available. not the number of stacks entered (even though it's the STACKS that increase when the user presses a key?). Here's how the program might look like while it is running: Figure 3 : The canvas before (left) and after (right) keys have been pressed.