? I don't understand why it should return a number. In Java, main methods are declared to have a void return type, where as in c/c++, it's common practice to have the main function return an int.
I would strongly recommend using helper methods, it'll make coding much easier.
Here's the general flow of how the game works, I'll leave implementing the helper methods up to you.
public class PigGame
{
public static void main(String[] args)
{
int playerScore = 0, compScore = 0;
boolean playerTurn = true;
while (playerScore < 100 && compScore < 100)
{
int tempScore = 0;
if (playerTurn)
{
if (getIfPlayerWantsToRollAgain())
{
int roll = (int)(Math.random()*5+1);
if (roll == 1)
{
playerTurn = false;
}
else
{
tempScore += roll;
}
}
else
{
playerScore += tempScore;
playerTurn = false;
}
else
{
compScore = doComputersTurn(compScore);
playerTurn = true;
}
}
}
public static boolean getIfPlayerWantsToRollAgain()
{
// what goes here?
}
public static int doComputersTurn(int compCurrentScore)
{
// what goes here?
}
}