Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. public static void main(String [] args)
  2. {
  3. Scanner console = new Scanner(System.in);
  4. String answer1,answer2,rules;
  5. int result,counter;
  6. boolean b;
  7. b=false;
  8. counter=0;
  9. System.out.println("Hey there, buddy! Wanna play a game of craps? Try your luck?");
  10. answer1=console.next();
  11. if (answer1.toLowerCase().charAt(0) == 'n'){
  12. System.out.println("Come back anytime, buddy!");
  13. System.exit(0);
  14. }
  15. System.out.println("Do you want to see the rules, buddy?");
  16. answer2=console.next();
  17. if (answer2.toLowerCase().charAt(0) == 'y'){
  18. Craps.rules();
  19. }
  20. do {
  21. Craps.play();
  22. counter++;
  23. } while(b);
  24. System.out.println("You played "+counter+" games before you lost. Good job, buddy! See yah, later!");
  25. System.exit(0);
  26. }
  27. public static boolean play()
  28. {
  29. int result=(int)(Math.random()*10+1);
  30. boolean b;
  31. if (result < (7)){
  32. b=true;
  33. return b;
  34. } else {
  35. b=false;
  36. return b;
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement