Skip to content

Commit d671039

Browse files
Alex LeeAlex Lee
authored andcommitted
Added MagicBall and HashBrowns
1 parent 6cb7f51 commit d671039

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

DataStructures/HashBrowns.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import java.util.HashSet;
2+
import java.util.Iterator;
3+
4+
public class HashBrowns {
5+
6+
public static void main(String[] args) {
7+
8+
HashSet<Integer> hashbrowns = new HashSet<Integer>();
9+
hashbrowns.add(13);
10+
hashbrowns.add(24);
11+
hashbrowns.add(5);
12+
13+
Iterator<Integer> it = hashbrowns.iterator();
14+
while(it.hasNext()) {
15+
System.out.println(it.next());
16+
}
17+
18+
19+
}
20+
21+
}

Programs/MagicBall.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import java.util.Random;
2+
import java.util.Scanner;
3+
4+
public class MagicBall {
5+
6+
public static void main(String[] args) {
7+
System.out.println("Enter your question");
8+
9+
Scanner scan = new Scanner(System.in);
10+
scan.next();
11+
scan.close();
12+
13+
Random rand = new Random();
14+
int r = rand.nextInt(5);
15+
System.out.println(r);
16+
17+
if(r == 0) {
18+
System.out.println("As I see it, yes.");
19+
} else if(r == 1) {
20+
System.out.println("Signs point to yes.");
21+
} else if(r == 2) {
22+
System.out.println("Reply hazy, try again.");
23+
} else if(r == 3) {
24+
System.out.println("Don't count on it.");
25+
} else if(r == 4) {
26+
System.out.println("Outlook not so good.");
27+
}
28+
29+
30+
}
31+
32+
}

0 commit comments

Comments
 (0)