import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.util.Random; import java.util.Arrays; /** * Class JavaJeopardy - write a description of the class here * * @author Chase Conner * @version JAVA SE 8 * @course CSCI 1130-01 * @date 11-15-15 */ public class JavaJeopardy extends JApplet implements ActionListener { //declares and initializes the Jeopardy buttons JButton[ ] JQuestion = { new JButton("10"), new JButton("20"), new JButton("30"), new JButton("40"), new JButton("50") }; /* * Declares and initializes the questions and answers arrays. * They are organized by each JButton whereas each button will have * random questions with the possible answers. */ String[] tenPointQuestion = { ("What is Graphics?"), ("For drawing methods, how do you specify where to draw?"), ("What do two forward slashes // create?") }; Object[] possibleAnswers1 = {"package", "method", "class"}; Object[] possibleAnswers2 = {"x and y coordinates", "pixels", "clicking on the screen"}; Object[] possibleAnswers3 = {"a header comment", "an inline comment", "an outline comment", "a secondary comment"}; String[ ] twentyPointQuestion = { ("Color mycolor = new Color(red, green, blue) does what?"), ("What data type would you use to tell the program to determine if an answer is correct or incorrect?"), ("What is an access modifier? (Hint: public, private, and protected)") }; Object[] possibleAnswers4 = {"sets the color", "creates a new color", "randomly sets the color as red, green, or blue"}; Object[] possibleAnswers5 = {"Integer", "Boolean", "String", "Character"}; Object[] possibleAnswers6 = {"A security feature that restricts access to the source code.", "Sets the level of access to classes, variables, and methods by other classes."}; String [ ] thirtyPointQuestion = { ("If an array begins at an index of 0 and ends at an index of 9, what index is the last element of the array located in?"), ("Which of the following is true about instance variables?"), ("What is needed to make the program properly examine each statement in a switch statement?") }; Object[] possibleAnswers7 = {10, 8, 9, 7}; Object[] possibleAnswers8 = {"Instance variables cannot be accessed by other classes.", "Instance variables are stored inside static memory.", "Instance variables are accessible to every class by declaring it outside of the method."}; Object[] possibleAnswers9 = {"break;", "stop;", "examine;", "halt;"}; String[ ] fortyPointQuestion = { ("In an enhanced for loop, does the element type have to match the data type of the array?"), ("What would the method call look like for public void employeeInfo( String name, String title, double salary)?"), ("Can fields and methods be inherited from a parent class to a subclass if their access modifier in set as private?") }; Object[] possibleAnswers10 = {"Yes", "No"}; Object[] possibleAnswers11 = {"void employeeInfo(String name, String title, double salary)", "methodCall(employeeInfo)", "employeeInfo(name, title, salary);"}; Object[] possibleAnswers12 = {"Yes", "No"}; String[ ] fiftyPointQuestion = { ("What is the default value for constructors?"), ("while (runAgain){ init() start() };: the following loop executes even if the user makes the boolean value false. What is missing inside of the code?"), ("What are mutator methods?") }; Object[] possibleAnswers13 = {"0", "nothing", "null"}; Object[] possibleAnswers14 = {"break;", "another bracket", "stop;"}; Object[] possibleAnswers15 = {"A method that returns the value of a field.", "A method that sets or gets a value of a field.", "A method that duplicates values of a field."}; Object[][] questionTenAnswers = new Object[][] {possibleAnswers1, possibleAnswers2, possibleAnswers3}; Random rand = new Random(); int n = rand.nextInt(2)+1; String inputBox; /** * Called by the browser or applet viewer to inform this JApplet that it * has been loaded into the system. It is always called before the first * time that the start method is called. */ public void init() { setLayout (new FlowLayout( ) ); //changes the layout to Flow Layout //adds the JButtons to the applet window for (int i=0; i