I am using a craps simulator and I am trying to return two values from the same method (or rather, I would like to).
When I wrote my return statement, I just tried putting "&". which compiled and works correctly; but I do not have access to the second return value.
public static int crapsGame(){ int myPoint; int gameStatus = rollagain; int d1,d2; int rolls=1; d1 = rollDice(); d2 = rollDice(); switch ( d1+d2 ) { case 7: case 11: gameStatus = win; break; case 2: case 3: case 12: gameStatus = loss; break; default: myPoint = d1+d2; do { d1=rollDice(); d2=rollDice(); rolls++; if ( d1+d2 == myPoint ) gameStatus = win; else if ( d1+d2 == 7 ) gameStatus = loss; } while (gameStatus == rollagain); }
When I return the value as:
gameStatus=crapsGame();
It sets varaible accordingly to win or lose, but if I try something simple, following this statement with:
rolls=crapsGame();
It is assigned the same value as gamestatus ... a 0 or 1 (win or lose). Any way I can access the second returned value? Or is there a completely different way of doing this?
source share