Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL/PHP Database Applications

Authors: Brad Bulger, Jay Greenspan, David Wall

2nd Edition

ISBN: 0764549634, 9780764549632

Students also viewed these Databases questions