-
Notifications
You must be signed in to change notification settings - Fork 1
/
ChooseTastyBeverage.java
108 lines (100 loc) · 3.55 KB
/
ChooseTastyBeverage.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
Program by: sp0rus
Program Objective: use java's random number generator to decide what beverage (coffee or tea) to drink, and if tea, decide what type of tea.
*/
import java.util.Random;
import java.util.Scanner;
public class ChooseTastyBeverage
{
public static void main( final String [] args )
{
Scanner console = new Scanner( System.in );
System.out.println( "This program will decide what you should drink using mind reading :)");
System.out.print( "Do you wish to continue [yes or no]? ");
String response = console.nextLine();
System.out.println( "Hold on while the computer attempts to read your mind \n"
+ "and see what you really want to drink...\n");
sleep();
Random generator = new Random ();
Random generator2 = new Random ();
while (response.equals("yes"))
{
final int coffee = 0;
final int tea = 1;
final int noClueDrink = 2;
int typeOfDrink = generator.nextInt(3);
if ( typeOfDrink == coffee )
{
printDrink("Coffee");
}
else if (typeOfDrink == tea )
{
final int green = 10;
final int black= 11;
final int white = 12;
final int rooibos = 13;
final int chai = 14;
final int herbal = 15;
final int noClueTea = 16;
printDrink("Tea");
int typeOfTea = generator2.nextInt(7) + 10;
if ( typeOfTea == green )
{
printTea("green");
}
else if ( typeOfTea == black )
{
printTea("black");
}
else if ( typeOfTea == white )
{
printTea("white");
}
else if ( typeOfTea == rooibos )
{
printTea("rooibos");
}
else if ( typeOfTea == chai )
{
printTea("chai");
}
else if ( typeOfTea == herbal )
{
printTea("herbal");
}
else if ( typeOfTea == noClueTea )
{
System.out.println( "Your mind was blocked, and I was unable to see \n"
+ "what tea really wanted, so you can try again \n"
+ "(and maybe end up with coffee!) or you can man\n"
+ "up and make your own decisions.\n");
}
}
else if ( typeOfDrink == noClueDrink )
{
System.out.println( "I couldn't read your mind, try again later or read your own mind you lazy bum.\n" );
}
System.out.print( "Hope you got your answer, if not, do you care to try again [yes or no]? " );
response = console.nextLine();
System.out.println();
}
System.out.println();
System.out.println( "Enjoy your tasty beverage!" );
}
private static void printDrink(String drink){
System.out.println("The drink that you subconsciouly desire is " + drink);
}
private static void printTea(String tea){
System.out.println("...and the type you are craving is " + tea + " tea.\n");
}
private static void sleep(){
try
{
Thread.sleep( 3000 );
}
catch ( InterruptedException e )
{
System.out.println( "awakened prematurely" );
}
}
}