Due: Monday, September 8th, by 11:59 PM
In this assignment, you will write a program to allow two players to play a game of Nim.
A game of Nim consists of one or more heaps of stones (or other objects). Players take turns taking 1 or more objects from one of the heaps. The last player to take a stone loses. So, the object of the game is to force the other player to take the last stone.
Here is an example session (user input in bold):
How many heaps? 3Size of heap 1? 3Size of heap 2? 4Size of heap 3? 5Player 1's turnHeaps: 1:3 2:4 3:5Pick from which heap? 3How many? 5Player 2's turnHeaps: 1:3 2:4 3:0Pick from which heap? 2How many? 4Player 1's turnHeaps: 1:3 2:0 3:0Pick from which heap? 1How many? 1Player 2's turnHeaps: 1:2 2:0 3:0Pick from which heap? 1How many? 1Player 1's turnHeaps: 1:1 2:0 3:0Pick from which heap? 1How many? 1Player 2 wins
Download CS201_Assign1.zip. Import it into your Eclipse workspace (File->Import...->General->Existing projects into workspace->Archive File). You will see a project called (surprise) CS201_Assign1 in the Package Explorer. The package edu.ycp.cs201.nim contains a file Nim.java which contains the main method of the program.
At a minimum, your program should allow the game to be played with 1 to 3 heaps. (Supporting any number of heaps is good: see Grading section below.)
Use the example session above as a model for what the program's prompts and output should look like.
Your grade will be determined as follows:
I expect you to use good coding style (identation, naming of identifiers, etc.) I will deduct points for programs that use poor style.
The following extra credit features may be implemented:
Do not copy any code from other students, web sites, etc. The program you submit must be your work alone. Failure to follow the Academic Integrity policy specified in the syllabus will be treated as Academic Dishonesty, and could have severe consequences.
Export your finished program to a zip file (right-click on the project, then Export...->Archive File). Upload the zip file to the marmoset server as project assign1. The server URL is
IMPORTANT: after uploading, you should download a copy of your submission and double-check it to make sure that it contains the correct files. You are responsible for making sure your submission is correct. You may receive a grade of 0 for an incorrectly submitted assignment.