Guest User

Untitled

a guest
Oct 3rd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.22 KB | None | 0 0
  1. import java.util.Random;
  2. import java.util.Scanner;
  3.  
  4. public class ball {
  5.     public static String question = "";
  6.  
  7.     public static void main(String[] args) {
  8.         System.out.println("***** EGO admin 8 ball *****");
  9.         ball();
  10.     }
  11.     private static void ball() {
  12.         System.out.println("What is your question young admin?");
  13.         Scanner scan = new Scanner(System.in);
  14.         question = scan.nextLine();
  15.         Random rand = new Random();
  16.         int answer = rand.nextInt(8) + 1;
  17.         String ret = "";
  18.        
  19.         switch(answer) {
  20.         case 1:
  21.             ret = "Blame Mayhem Death";
  22.             break;
  23.         case 2:
  24.             ret = "Ask me later";
  25.             break;
  26.         case 3:
  27.             ret = "I flipped a coin";
  28.             break;
  29.         case 4:
  30.             ret = "Yes";
  31.             break;
  32.         case 5:
  33.             ret = "No";
  34.             break;
  35.         case 6:
  36.             ret = "I fat fingered your name";
  37.             break;
  38.         case 7:
  39.             ret = "You're a troll";
  40.             break;
  41.         default:
  42.             ret = "Ball broken, insert $1 to fix";
  43.         }
  44.         System.out.println("Question: " + question);
  45.         System.out.println("Answer: " + ret);
  46.         while(true) {
  47.             System.out.println("Play again? 0 - no 1 - yes");
  48.             Scanner answerScan = new Scanner(System.in);
  49.             int response = answerScan.nextInt();
  50.             if(response == 1) {
  51.                 ball();
  52.             }
  53.             else {
  54.                 System.exit(0);
  55.             }
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment