You don't have any comments. Especially for homework, you need comments. In real life you probably need them even more. Most programs worth using are going to be too complex to understand withtout effort or comments, and the less effort the better. Good to get in the habit. Your variable names are good and descriptive though, that's a good thing.
Now, for example:
Code:
stones1 = rand.nextInt(16) + 15;
stones2 = rand.nextInt(16) + 15;
stones3 = rand.nextInt(16) + 15;
stones4 = rand.nextInt(16) + 15;
This isn't a complex program, but that kind of thing is best done with an array. If you find yourself copying and pasting lines over and over, you're probably better off abstracting it into a data structure (array, hash, queue) or function. For example, you can define a constant called NUMBER_OF_PILES or something, and do things like
Code:
for(int c=0; c< NUMBER_OF_PILES; c++) {
/*Do some stuff with the piles*/
}
And if you decide one day you want to change your game to have 47 piles, you change it in one place at the top of your program and it works.
Same thing with takeStones1, takeStones2, etc. Better to have a function called takeStones, and pass it an int parameter to tell which pile to take from. Do a check on the parameter to make sure it's not greater than NUMBER_OF_PILES so you don't throw an array out of bounds error.
That will also let you replace things like
Code:
ans = console.readInt();
switch(ans)
{
case 1: takeStones1(); break;
case 2: takeStones2(); break;
case 3: takeStones3(); break;
case 4: takeStones4(); break;
}
with something like
Code:
ans = console.readInt();
takeStones(ans);