Threesuns

Email the Instructor

Contact

All Semesters

Semesters

All Courses

Courses

2013Fall

08.20.12 - 12.16.12

Introduction to Java Programming

CSCI2133

Monday Wednesday
04:00 PM - 05:20 PM

GUI Nim

Lab05

Objective: Use of Objects and Classes and GUI components

pastdue

Submit Your Solution

Lab05

Request a Copy of your Solution

Lab05

Requirements

Comments placed in each source code file.5 pts
Files put into JAR format and is made executable.5 pts
Application source and class files included.5 pts
Program compiles and executes without errors5 pts
Program allows required user inputs10 pts
Program performed input error checking20 pts
Game play executed correctly20 pts
Program uses optimal strategy in play10 pts
GUI functions properly (appearance and user input)10 pts
Player class created and used10 pts
Total100 pts

Instructions

For this lab you will need to recreate the game of NIM from lab2 using classes and a graphical user interface. A player class should be created that will encapsulate the properties and behaviors of a player in the game. The Player class should be able to be used for both computer and human players and should include the pile (number of stones remaining) as a data member as well as methods for executing a human player's move and the computer player's move (call them move( int s ) and automove( )).

The interface for the game should consist of:

  • Three dialog boxes - one to allow the user to enter the number of stones to start with, one to allow the user to select who goes first in the game, and the last to announce the winner of the game.
  • Two JButtons - one for taking one stone, the other for taking two stones.
  • Two JTextAreas - one for displaying the moves of the game and the other for showing a representation of the stone pile.
  • Any additional components (JScrollPanes, JLabels, etc.) that are needed can be added at your discretion.

Example:

Your version of this program, because it is an application, not an applet like the example given above, does not require a 'Start Game' button. I included this in the applet version because without it, you would have been required to play a game every time you visited this page.