I'm creating an applet that will open up the ACM package and play a game.
The game works like this:
-There are 2 players - One human and one computer player
-The human player declares how many sticks will be used in the pile
-The human player decides if they want to play against a computer with a greedy strategy, a timid strategy, or a perfect strategy.
-Each player goes back and forth removing sticks 1, 2, or 3 at a time until the last stick is removed
-When the last stick is removed that person is declared the loser.
So I have to have a Java Interface for player which greedyplayer, timidplayer, and cleverplayer will all use.
And I have an engine class which will basically run the entire game. Then I will have a class that keeps track of the pile. Right now this is how I have it setup:
The engine runs in main starting a scanner and that will ask how many sticks you would like to play with (in the console) and then it sends that information as a parameter to the pile class. The pile class will draw the canvas and the sticks with this information using the ACM graphics package. This is all I want to be able to do so far but I'm stuck. I think I could take it from here as I've written a couple different text based versions of this game.
My problem is that I can't seem to be able to do anything. Here is my main:
Code:
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in;
in = new Scanner(System.in);
System.out.print("Enter the number of sticks to play the game with: ");
int numSticks = in.nextInt();
NimEngine pile = new NimEngine();
pile.create(numSticks);
}
But it never even asks for the number of sticks in the console, it simply draws the canvas and seems to basically stop doing anything else...
And I'm using Eclipse for Mac if that makes a difference, thanks so much!
Bookmarks