A Magic 8-Ball (Wikipedia) is a toy that pretends to predict the future by answering Yes/No questions posed to it.
Write a Magic8Ball
class with two methods. The shake()
method identifies a random response from the Magic 8-Ball, but doesn't show it. The showResult()
method returns one of the String
responses randomly chosen from the ball's selection of responses. Your answers can be selected from among these five, or make up your own.
Then write a Magic8BallTester
program that creates a Magic8Ball
object, has the user enter a Yes/No question, and then calls the methods in response to a user's question.
Sample Interaction
Welcome to the Magic 8 Ball!
Ask a Yes/No question and I will tell you if your question will come true!
Your question: Will I get an A in this class?
Shaking the ball...
Viewing the result...
My response: Reply hazy. Ask again later.
Thanks for using the Magic 8 Ball!