|
@@ -3,128 +3,165 @@ package io.zipcoder.casino;
|
3
|
3
|
import java.util.Random;
|
4
|
4
|
import java.util.Scanner;
|
5
|
5
|
|
6
|
|
-public class SlotMachine implements Game, Gamble {
|
|
6
|
+import static java.lang.Thread.sleep;
|
7
|
7
|
|
8
|
|
-// implemented from gamble
|
9
|
|
- @Override
|
10
|
|
- public void Bet(int betAmount) {
|
|
8
|
+public class SlotMachine implements Game, Gamble {
|
|
9
|
+ private int betAmount;
|
|
10
|
+ private int payout=0;
|
11
|
11
|
|
|
12
|
+ public SlotMachine(int betAmount) {
|
|
13
|
+ this.betAmount = betAmount;
|
12
|
14
|
}
|
13
|
15
|
|
|
16
|
+ // implemented from gamble
|
14
|
17
|
@Override
|
15
|
|
- public int Payout(int payoutAmount) {
|
16
|
|
- return 0;
|
17
|
|
- }
|
18
|
|
-
|
|
18
|
+ public void bet(int betAmount) {
|
|
19
|
+ this.betAmount= betAmount;
|
19
|
20
|
|
20
|
|
- // implementd from game
|
|
21
|
+ }
|
21
|
22
|
|
22
|
23
|
@Override
|
23
|
|
- public void Quit() {
|
|
24
|
+ public void payout(){
|
|
25
|
+ System.out.println("Your payout amount for slot machine is: $" +payout +"\n");
|
24
|
26
|
|
25
|
27
|
}
|
26
|
28
|
|
27
|
|
- @Override
|
28
|
|
- public void StartGame() {
|
29
|
|
- System.out.println("Welcome to Slot Machine!");
|
30
|
|
-
|
31
|
29
|
|
32
|
|
- }
|
|
30
|
+ // implementd from game
|
33
|
31
|
|
34
|
32
|
@Override
|
35
|
|
- public void StartRound() {
|
|
33
|
+ public void quit() {
|
36
|
34
|
|
37
|
35
|
}
|
38
|
36
|
|
39
|
|
- public static void main(String[] args) {
|
40
|
|
-
|
41
|
|
-
|
42
|
|
- //System.out.println("Enter the amount of money you wan to enter into the slot machine");
|
43
|
|
- Scanner scanner = new Scanner(System.in);
|
44
|
|
-
|
45
|
|
- String word="";
|
46
|
|
- String outputword="";
|
47
|
|
- String word1="";
|
48
|
|
- String word2="";
|
49
|
|
- String word3="";
|
50
|
|
- int useramount=0;
|
51
|
|
- char playAgain= 'y';
|
52
|
|
- double totalBet=0;
|
53
|
|
-
|
54
|
|
- while(playAgain=='y'){
|
|
37
|
+ @Override
|
|
38
|
+ public void startGame() {
|
|
39
|
+ System.out.println("You are all set to play a new slot game..zrrr..!"+"\n");
|
|
40
|
+ try {
|
|
41
|
+ Thread.sleep(3000);
|
|
42
|
+ } catch (InterruptedException e) {
|
|
43
|
+ e.printStackTrace();
|
|
44
|
+ }
|
|
45
|
+ System.out.println("Your slot is in progress"+"\n");
|
55
|
46
|
|
56
|
|
- outputword="";
|
|
47
|
+ try {
|
|
48
|
+ Thread.sleep(3000);
|
|
49
|
+ } catch (InterruptedException e) {
|
|
50
|
+ e.printStackTrace();
|
|
51
|
+ }
|
57
|
52
|
|
58
|
|
- Random rand = new Random();
|
|
53
|
+ String word="";
|
|
54
|
+ String outputword="";
|
|
55
|
+ String word1="";
|
|
56
|
+ String word2="";
|
|
57
|
+ String word3="";
|
|
58
|
+ //int useramount=0;
|
|
59
|
+ char playAgain= 'y';
|
|
60
|
+ double totalBet=0;
|
|
61
|
+
|
|
62
|
+ // while(playAgain=='y'){
|
|
63
|
+
|
|
64
|
+ outputword="";
|
|
65
|
+
|
|
66
|
+ Random rand = new Random();
|
|
67
|
+
|
|
68
|
+ for(int i = 1; i <=3;i++){
|
|
69
|
+ int randnum = rand.nextInt(6);
|
|
70
|
+ //System.out.println(randnum);
|
|
71
|
+
|
|
72
|
+ if(randnum == 0) {
|
|
73
|
+ word = "DOG";
|
|
74
|
+ // System.out.println("dog");
|
|
75
|
+ }
|
|
76
|
+ else if(randnum == 1) {
|
|
77
|
+ word = "CAT";
|
|
78
|
+ // System.out.println("cat");
|
|
79
|
+ }
|
|
80
|
+ else if(randnum == 2) {
|
|
81
|
+ word = "RABBIT";
|
|
82
|
+ // System.out.println("kjsd");
|
|
83
|
+ }
|
|
84
|
+ else if(randnum == 3) {
|
|
85
|
+ word = "SQUIRREL";
|
|
86
|
+ // System.out.println("sq");
|
|
87
|
+ }
|
|
88
|
+ else if(randnum == 4) {
|
|
89
|
+ word = "FISH";
|
|
90
|
+ // System.out.println("ff");
|
|
91
|
+ }
|
|
92
|
+ else if(randnum == 5) {
|
|
93
|
+ word = "MOUSE";
|
|
94
|
+ // System.out.println("mm");
|
|
95
|
+ }
|
|
96
|
+ // outputword += word;
|
|
97
|
+
|
|
98
|
+ if(i == 1){
|
|
99
|
+ word1= word;
|
|
100
|
+ // System.out.println(i);
|
|
101
|
+ }
|
|
102
|
+
|
|
103
|
+ else if(i == 2){
|
|
104
|
+ word2= word;
|
|
105
|
+ // System.out.println(i);
|
|
106
|
+ }
|
|
107
|
+
|
|
108
|
+ else if(i == 3){
|
|
109
|
+ word3= word;
|
|
110
|
+ // System.out.println(word3);
|
|
111
|
+ }
|
|
112
|
+ }
|
|
113
|
+ outputword= "[ " + word1+ " ]" + " " + "[ " + word2 + " ]" + " "+ "[ " + word3 + " ]" + "\n" ;
|
|
114
|
+ //System.out.println(outputword);
|
59
|
115
|
|
60
|
|
- for(int i = 1; i <=3;i++){
|
61
|
|
- int randnum = rand.nextInt(6);
|
62
|
116
|
|
63
|
|
- if(randnum ==0) {
|
64
|
|
- word = "DOG";
|
65
|
|
- }
|
66
|
|
- else if(randnum ==1) {
|
67
|
|
- word = "CAT";
|
68
|
|
- }
|
69
|
|
- else if(randnum ==2) {
|
70
|
|
- word = "RABBIT";
|
71
|
|
- }
|
72
|
|
- else if(randnum ==3) {
|
73
|
|
- word = "SQUIRREL";
|
74
|
|
- }
|
75
|
|
- else if(randnum ==4) {
|
76
|
|
- word = "FISH";
|
77
|
|
- }
|
78
|
|
- else if(randnum ==5) {
|
79
|
|
- word = "MOUSE";
|
80
|
|
- }
|
81
|
|
- // outputword += word;
|
|
117
|
+ if(((!word1.equals(word2)) )&& ((!word1.equals(word3))) && ((!word2.equals(word3)))){
|
82
|
118
|
|
83
|
|
- if(i==1){
|
84
|
|
- word1= word;
|
|
119
|
+ outputword= outputword + "\n"+" You have won $0";
|
|
120
|
+ payout=0;
|
85
|
121
|
}
|
86
|
122
|
|
87
|
|
- else if(i==2){
|
88
|
|
- word2= word;
|
89
|
|
- }
|
|
123
|
+ else if( ((word1.equals(word2) == true) && (word1.equals(word3)== false )) || ((word1.equals(word3)== true) && (word1.equals(word2)==false)) || ( (word2.equals(word3)==true) && (word2.equals(word1))==false)){
|
90
|
124
|
|
91
|
|
- else if(i==3){
|
92
|
|
- word3= word;
|
|
125
|
+ outputword= outputword + "\n" +" You have won $" + (betAmount*2);
|
|
126
|
+ payout=betAmount*2;
|
93
|
127
|
}
|
94
|
|
- }
|
95
|
|
- outputword+= "[ " + word1+ " ]" + " " + "[ " + word2 + " ]" + " "+ "[ " + word3 + " ]" ;
|
96
|
128
|
|
97
|
129
|
|
98
|
|
- if((word1 != word2) && (word1 != word3) && (word2 != word3)){
|
|
130
|
+ else if( ((word1.equals(word2)==true) && (word1.equals(word3)==true) ) && ((word2.equals(word1)==true) && (word2.equals(word3)==true)) && ( (word3.equals(word1)==true) && (word3.equals(word2)==true))){
|
99
|
131
|
|
100
|
|
- outputword= outputword + "/n You have won $0";
|
101
|
|
- }
|
|
132
|
+ outputword= outputword + "\n" + "You have won $" + (betAmount*3);
|
|
133
|
+ payout=betAmount*3;
|
|
134
|
+ }
|
102
|
135
|
|
103
|
|
- else if( ((word1==word2) && (word1 != word3) ) || ((word1== word3) && (word1 != word2)) || ( (word2== word3) && (word2 != word1))){
|
|
136
|
+ System.out.println(( outputword + "\n" ));
|
104
|
137
|
|
105
|
|
- outputword= outputword + "/n You have won $" + (useramount*2);
|
|
138
|
+ try {
|
|
139
|
+ Thread.sleep(2000);
|
|
140
|
+ } catch (InterruptedException e) {
|
|
141
|
+ e.printStackTrace();
|
106
|
142
|
}
|
107
|
143
|
|
108
|
144
|
|
109
|
|
- else if( ((word1==word2) && (word1 ==word3) ) && ((word2==word1) && (word2 ==word3)) && ( (word3== word1) && (word3 ==word2))){
|
110
|
145
|
|
111
|
|
- outputword= outputword + "/n You have won $" + (useramount*3);
|
112
|
146
|
}
|
113
|
147
|
|
114
|
|
- System.out.println(( outputword + "/n/n/nDo you want to play again? /n/nPress y for yes, any key for no.").charAt(0));
|
115
|
148
|
|
116
|
|
- //System.out.println(outputword);
|
117
|
149
|
|
118
|
150
|
|
119
|
151
|
|
120
|
|
- }
|
121
|
152
|
|
|
153
|
+ @Override
|
|
154
|
+ public void startRound() {
|
122
|
155
|
|
|
156
|
+ }
|
123
|
157
|
|
|
158
|
+ /* public void main(String[] args) {
|
124
|
159
|
|
125
|
160
|
|
|
161
|
+ //System.out.println("Enter the amount of money you wan to enter into the slot machine");
|
|
162
|
+ //Scanner scanner = new Scanner(System.in);
|
126
|
163
|
|
127
|
|
-}
|
128
|
164
|
|
|
165
|
+ }*/
|
129
|
166
|
}
|
130
|
167
|
|