Advertisement
NewbProgrammer

Craps

Dec 19th, 2012
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.93 KB | None | 0 0
  1.             int iDie1, iDie2;
  2.  
  3.             iDie1 = rollDice();
  4.             iDie2 = rollDice();
  5.  
  6.             int iSum = iDie1 + iDie2;
  7.  
  8.             String sRoll = "You rolled " + iDie1 + "+" + iDie2 + "=" + iSum + ".\n";
  9.             String sOutput = "";
  10.             int iPoint = 0;
  11.             int iRollCount = 0;
  12.  
  13.             if(iSum == 7 || iSum == 11)
  14.             {
  15.                 sOutput = sRoll + "You win because you got a natural :)\n";
  16.             }
  17.             else if(iSum == 2 || iSum == 3 || iSum == 12)
  18.             {
  19.                 sOutput = sRoll + "You lost because you got a crap out :(\n";
  20.             }
  21.             else if(iRollCount == 0)
  22.             {
  23.                 iPoint = iSum;
  24.                 sOutput = sRoll + "Point is: " + iPoint + ".\n";
  25.                 iRollCount++;
  26.             }
  27.             else if(iRollCount != 0 && iPoint == iSum)
  28.             {
  29.                 sOutput = sRoll + "You win because your roll matches point ;)\n";
  30.             }
  31.             else if(iRollCount != 0 && iSum == 7)
  32.             {
  33.                 sOutput = sRoll + "You lost because your roll matches 7 :(\n";
  34.             }
  35.             else
  36.             {
  37.                 sOutput = sRoll;
  38.             }
  39.  
  40.             writeMessage(sOutput);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement