Before we begin writing pseudocode, it is important to take a minute to write instructions for the magic 8 ball. Remember the recipe format we used earlier in phase one? These instructions will use the same format.
You will write the ingredients and instructions needed to make the magic 8-ball website work. Skillcrush provides students with a couple of hints to help students write these instructions.
Solution
First, letβs tackle the ingredients. The ingredients will later become an object and properties in our pseudocode. In this project, you will need two ingredients.
All you will need is a magic 8 ball and a list of answers. We donβt need to go into detail about what answers we want to use in our Magic 8 ball just yet. We will eventually put together our list later in this course.
Ingredients
* A magic 8-ball
* A list of answers
Now that the ingredients are done, we are ready to turn our attention to the instructions. There will be three steps the magic 8 ball needs to work. Underneath the ingredients, we will write down each of the three steps.
First, the Magic 8 ball needs a question. So step one is where the computer will get the user to ask a question about something that might happen in the future. Once the user submits a question, it is time to figure out how to get the answer.
The next step is where the Magic 8 ball will randomly decide what answer to pick. This is where the ball will shake as it figures out the answer. The last step is where the answer is displayed on the ball. So step three is where the magic 8 ball will respond and show the message.
Finished Pseudocode
Thatβs a wrap for this challenge. Hereβs a look at the instructions we just created for this project. You can add more instructions if you like, but remember the abstraction principle and keep the instructions to the bare minimum.
Instructions
1. Ask the Magic 8-Ball a question about a future event.
2. Shake the 8-ball
3. The 8-ball responds with an answer.
This post was originally published on July 5, 2021 on DEV. I made minor changes to the original post for CodeNewbie.
Top comments (1)
can we use ia catala to generate 8 ball instructions would it be helpful to generate valid content.