Nim Project
From Huben's Wiki
(→Graphical Nim) |
(→C-:) |
||
Line 16: | Line 16: | ||
* The main() should create an instance of Nim and display the stones using the toString() method without directly calling toString(). | * The main() should create an instance of Nim and display the stones using the toString() method without directly calling toString(). | ||
===C-:=== | ===C-:=== | ||
− | * Use a Scanner in a loop to input a row | + | * Use a Scanner in a loop to input a row LETTER (either upper or lower case) and number of stones to remove. |
* The loop should only exit when a valid move has been selected. | * The loop should only exit when a valid move has been selected. | ||
− | * | + | * Use Scanner.nextLine() instead of nextInt(): it is more robust. |
− | ** | + | * tests for valid row should reject: |
− | ** not empty row | + | ** a simple return without typing anything |
− | ** | + | ** characters that are not row names |
− | ** | + | ** empty row names |
− | ** | + | * tests for valid number of stones should reject: |
− | ** | + | ** a simple return without typing anything |
+ | ** zero | ||
+ | ** negative numbers | ||
+ | ** really large numbers such as 12345678901234567890 | ||
+ | ** more stones than in the row | ||
+ | ** anything not a number | ||
+ | * the easy way is to just look at the first character, if it exists, for row or stones | ||
+ | * it would be nicer if we could type b2 at one input to take two from row B. | ||
===C+=== | ===C+=== |