Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private class PlayButtonHandler implements ActionListener
- {
- public int rollDice()
- {
- int iDie = (int)(Math.random()*6) +1;
- return (iDie);
- }
- public void writeMessage(String sOutput)
- {
- jtaGame.append(sOutput);
- }
- public void actionPerformed(ActionEvent e)
- {
- rollDice();
- int iDie1 = new rollDice();
- int iDie2 = new rollDice();
- int iSum = iDie1 + iDie2;
- String sRoll = "You rolled " + iDie1 + "+" + iDie2 + "=" + iSum + ".\n";
- String sOutput = "";
- int iPoint = 0;
- switch(iSum)
- {
- case 7:
- case 11:
- sOutput = sRoll + "You win because you got a natural :)";
- break;
- case 2:
- case 3:
- case 12:
- sOutput = sRoll + "You lost because you got a crap out :(";
- default:
- sOutput = sRoll + "Point is: " + iSum + ".";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment