I have a program that a friend wrote for me in Java, however I'm trying to put it in C++ and I don't know Java myself. Does anyone know somewhere that I can get it translated? Or maybe someone who has time to translate it themselves?
It all looks vaguely familiar, but I'm not sure of a lot of the corresponding commands while translating.
This is basically what I have,
System.out.println("Welcome to the game of Pig!");
System.out.println();
gameOver = false;
while (!gameOver)
{
// HUMAN'S TURN
turnScore = 0;
turnOver = false;
do
{
dice = (int) (Math.random() * 6) + 1;
System.out.println("You rolled: " + dice);
if (dice == 1)
{
System.out.println("You lose your turn!" +
" Your total is " + scoreHuman);
turnScore = 0;
turnOver = true;
}
else
{
turnScore += dice;
System.out.println("Your turn score is "
+ turnScore + " and your " +
"total score is " + scoreHuman);
System.out.println("If you hold, you will have " +
(turnScore + scoreHuman) + " points.");
System.out.println("Enter 'r' to roll again, " +
"'s' to stop.");
s = keyboard.next();
if (s.equals("s"))
turnOver = true;
}
} while (!turnOver);
// Add in any points the human got
scoreHuman += turnScore;
System.out.println("Your score is " + scoreHuman);
// Check for human winning
if (scoreHuman >= 100)
{
System.out.println("YOU WIN!");
gameOver = true;
return; // Exit immediately if win
}
//Computer Turn - basic order as above
I would really appreciate it!