import java.util.Scanner;
import java.util.Random;
import java.applet.Applet;
import java.awt.*;
public class Magic8Ball{
public static void main(String []args) {
String question;
Scanner scan = new Scanner(System.in);
Random generator = new Random();
System.out.println("Ask away. (Preferably yes or no questions");
question = scan.next();
Answer quest = new Answers(generator.nextInt(20)+1);
System.out.println(quest.answers());
}
public class Answer{
private int selection;
private String response;
public void Answers (int x) {
selection = x;
}
public String Answer() {
switch (selection) {
case 1: response = "It is certain"; break;
case 2: response = "It is decidedly so"; break;
case 3: response = "Without a doubt"; break;
case 4: response = "Yes – definitely"; break;
case 5: response = "You may rely on it"; break;
case 6: response = "As I see it, yes"; break;
case 7: response = "Most likely"; break;
case 8: response = "Outlook good"; break;
case 9: response = "Signs point to yes"; break;
case 10: response = "Yes"; break;
case 11: response = "Reply hazy, try again"; break;
case 12: response = "Ask again later"; break;
case 13: response = "Better not tell you now"; break;
case 14: response = "Cannot predict now"; break;
case 15: response = "Concentrate and ask again"; break;
case 16: response = "Don't count on it"; break;
case 17: response = "My reply is no"; break;
case 18: response = "My sources say no"; break;
case 19: response = "Outlook not so good"; break;
case 20: response = "Very doubtful"; break;
default: response = "nothing";
}
return response;
}
}
public class DrawBallextendsApplet {
public void paint(Graphics page) {
final int MID =150;
setBackground(Color.cyan);
page.setColor(Color.black);
page.fillOval(0,0,300,300);
page.setColor(Color.blue);
page.fillOval(75,60,150,150);
page.setColor(Color.white);
page.drawLine(MID-65,100, MID+65,100);
page.drawLine(MID-65,100, MID,210);
page.drawLine(MID+65,100, MID,210);
}
}
}