Skip to content

Commit f3bb860

Browse files
committed
refactor: lowercase
1 parent cd338d3 commit f3bb860

File tree

3 files changed

+122
-0
lines changed

3 files changed

+122
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.codedifferently.lesson16.shawndunsmore;
2+
3+
public enum BuyType {
4+
BONUS_BUY,
5+
DOUBLE_CHANCE,
6+
NORMAL_BUY,
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.codedifferently.lesson16.shawndunsmore;
2+
3+
public class InvalidPayAmountException extends Exception {
4+
5+
public InvalidPayAmountException(String message) {
6+
super(message);
7+
}
8+
}
9+
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
package com.codedifferently.lesson16.shawndunsmore;
2+
3+
import java.util.ArrayList;
4+
import java.util.Collections;
5+
6+
public class SlotMachine {
7+
private int numOfSlots;
8+
private int payAmount;
9+
private String name;
10+
private BuyType buyType;
11+
private ArrayList<String> iconList;
12+
private int moneyNeeded;
13+
14+
public SlotMachine(
15+
int numOfSlots,
16+
int payAmount,
17+
String name,
18+
BuyType buyType,
19+
ArrayList<String> iconList,
20+
int moneyNeeded) {
21+
this.numOfSlots = numOfSlots;
22+
this.payAmount = payAmount;
23+
this.name = name;
24+
this.buyType = buyType;
25+
this.iconList = iconList;
26+
this.moneyNeeded = moneyNeeded;
27+
}
28+
29+
public int getNumOfSlots() {
30+
return numOfSlots;
31+
}
32+
33+
public int getPayAmount() {
34+
return payAmount;
35+
}
36+
37+
public String getName() {
38+
return name;
39+
}
40+
41+
public BuyType getBuyType() {
42+
return buyType;
43+
}
44+
45+
public ArrayList<String> getIconList() {
46+
return iconList;
47+
}
48+
49+
public int payOut() {
50+
if (buyType.equals(BuyType.DOUBLE_CHANCE)) {
51+
return payAmount * 2;
52+
}
53+
54+
if (buyType.equals(BuyType.BONUS_BUY)) {
55+
return payAmount * 3;
56+
}
57+
return payAmount;
58+
}
59+
60+
public ArrayList<String> spin(int money) throws InvalidPayAmountException {
61+
if (money < moneyNeeded) {
62+
throw new InvalidPayAmountException("Amount inavalid");
63+
}
64+
Collections.shuffle(iconList);
65+
return iconList;
66+
}
67+
68+
public ArrayList<String> spin(int money, int numOfSpins) throws InvalidPayAmountException {
69+
if (money < moneyNeeded) {
70+
throw new InvalidPayAmountException("Amount inavalid");
71+
}
72+
for (int i = 0; i < numOfSpins; i++) {
73+
Collections.shuffle(iconList);
74+
}
75+
76+
return iconList;
77+
}
78+
79+
public int getMoneyNeeded() {
80+
return moneyNeeded;
81+
}
82+
83+
public void setNumOfSlots(int numOfSlots) {
84+
this.numOfSlots = numOfSlots;
85+
}
86+
87+
public void setPayAmount(int payAmount) {
88+
this.payAmount = payAmount;
89+
}
90+
91+
public void setName(String name) {
92+
this.name = name;
93+
}
94+
95+
public void setBuyType(BuyType buyType) {
96+
this.buyType = buyType;
97+
}
98+
99+
public void setIconList(ArrayList<String> iconList) {
100+
this.iconList = iconList;
101+
}
102+
103+
public void setMoneyNeeded(int moneyNeeded) {
104+
this.moneyNeeded = moneyNeeded;
105+
}
106+
}

0 commit comments

Comments
 (0)