Question
The One Row Nim Applet Create an applet to play the One Row Nim game. The resulting applet window should look something like this: Results:
The One Row Nim Applet
Create an applet to play the One Row Nim game.
The resulting applet window should look something like this:
Results: Sticks=6, player=2
Results: Sticks=4, player=1
Results: Sticks=1, player=2
Results: Sticks=0, player=1
Game over!
Options: Pick one stick, Pick two sticks, Pick three sticks
Begin by reviewing the Greeting panel applet we discussed in class. The source for the three classes used in that applet can be found here:
http://turing.cs.trincoll.edu/~ram/jjj/src/ch4/greetergui/Greeter.java
http://turing.cs.trincoll.edu/~ram/jjj/src/ch4/greetergui/GreeterGUIPanel.java
http://turing.cs.trincoll.edu/~ram/jjj/src/ch4/greetergui/GreeterPanelApplet.java
The source for your OneRowNim class can be found here:
http://turing.cs.trincoll.edu/~ram/jjj/src/ch3/onerownim3/OneRowNim.java
Review that class to determine which constructor and methods you will need for your applet. You may add any new methods you feel are necessary to get the behavior seen in the window above. I recommend you add a toString() method to return the values stored in the class.
In addition to displaying the results of each move in the JTextArea, you will need to define 3 JButton components. The action for each button is as follows:
Button 1 pressed remove 1 stick from the pile and display the results.
Button 2 pressed remove 2 sticks from the pile and display the results.
Button 3 pressed remove 3 sticks from the pile and display the results.
Your finished project should contain three classes named as follows:
OneRowMin
OneRowMinGUIPanel
OneRowMinPanelApplet
Show your 3 Java (.java) files
Hint of the day: You can change the name of a class by highlighting the .java file and right clicking to select Refactor -> Rename . This will change all the class name references in your project. You can use the same procedure to change the name of a variable or method within your class.
Extra Credit: Create another button on the Applet that restarts the game.
PLEASE DO NOT COPY AND PASTE OFF THE INTERNET!
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