Question: Magic8Ball class: The Magic8Ball class should simulate a magic 8-ball that is able to provide answers to different questions. Unlike a typical magic 8-ball which


Magic8Ball class: The Magic8Ball class should simulate a magic 8-ball that is able to provide answers to different questions. Unlike a typical magic 8-ball which usually only provides generic "yes" or "no" answers, your class should analyze the question that has been asked and respond intelligently. Your class should only contain a single static method based on the API below. CsCl160lab06 Lab Assignment 6 instructions Spring 2023 Your Magic8Ball class should be able to return at least 5 different responses to each of the 7 different question categories identified above. The responses should be retumed randomly (Use the Random class) in an approximately uniform (e.g. each response is about as likely as any other) manner. Create a GUI class using the JFrame Form option in NetBeans to make a client program for you Magic8Ball class. You will want to override the paint method (make sure to call the superclass version of the method inside the body) in order to draw some simple graphics to visually create your magic 8-ball. You can create something that looks similar to the example below: When the user clicks the button to shake the 8-ball you should take their question from the JTextField and use it as an argument to the static askQuestion method of your Magie8Ball class. It is recommended that you store the response in an instance variable and call the drawString method inside of the paint method in order to visually represent the response. For an extra challenge, try to see if you can always make the response approximately centered. For an even greater challenge see if you can split up long responses over multiple lines, each of which is centered. In order to get your application to redraw the screen in response to clicking the button in order to display the changes that have occurred, you should call the repaint method (your class will have CSCl160lab06 Spring 202 Lab Assignment 6 Instructions inherited this method from JErame) as the last statement inside of the method body for the listener code associated with that button
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
