How to Solve Objects in Magic 8 Ball Project

Sarah Dye - Jul 5 '21 - - Dev Community

Now that we have our instructions, we are ready to start turning what we just wrote into pseudocode. In this challenge, we are going to concentrate on turning the ingredients into objects. You will take what you learned about objects to create objects and properties for the Magic 8 ball. Skillcrush hints students will only need one object and one property for your project.

Solution

The object we will create for our project is the 8 ball. First, create an object using the object keyword. After that, we will name our object.

I’m going to name the object Magic 8-Ball. We can now turn our attention to the properties. There are plenty of properties you can set for this object, but we are going to use the rule of abstraction here and just get the bare minimum of what is needed to make this project work.

The finished project needs to show answers to a user’s question so the only other property we will need is a list of answers. Underneath the line for our magic 8-ball object, you will create a property using the property keyword. After this keyword, it will be the list of answers the ball will have and randomly picked when the ball is shaken.

Finished Pseudocode

The first step of the magic 8-ball prep is completed! Here’s a look at how your object might look in your pseudocode. Put this pseudocode aside for now. We’ll add more to it later in this lesson.

OBJECT Magic 8-Ball
    PROPERTY list of answers
Enter fullscreen mode Exit fullscreen mode
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .