Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program that simulates a Magic 8 Ball, which is a fortune - telling toy that displays a random response to a yes or
Write a program that simulates a Magic Ball, which is a fortunetelling toy that displays a random response to a yes or no question.
You should write a program consisting of two classes, one class containing the main method and the second class containing the MagicEightBall class from which a Magic Ball object will be created.
The main method will ask the user for a yesno question and generate a random number which shall be passed to the MagicEightBall object.
Use the Random class to generate a random number between and within the main method.
The MagicEightBall class will have a constructor and methods to access an array or ArrayList object.
Below, you will see a list of responses such as "I don't think so "Yes, of course", Im not sure", and so forth.
The responses should be placed into an array or ArrayList object using a constructor.
The random number passed to the MagicEightBall class shall be used to select one of the responses from the array or ArrayList object.
The response retrieved from the array or ArrayList object shall be passed back to the main method where it will be displayed to the user.
The program should repeat until the user is ready to quit.
Responses to the user's question include the following:
Yes, of course!
Without a doubt, yes.
You can count on it
For sure!
Ask me later.
Im not sure.
I can't tell you right now.
I'll tell you after my nap.
No way!
I don't think so
Without a doubt, no
The answer is clearly NO
Step 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