Skip to content

Commit c49efe7

Browse files
committed
Feat: Adds Shawn Dunsmore Jr Lesson 16 SlotMachine.java and SlotMachineTest.java Updated
1 parent 181efaa commit c49efe7

File tree

2 files changed

+46
-19
lines changed

2 files changed

+46
-19
lines changed

lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/ShawnDunsmore/SlotMachine.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,41 +30,41 @@ public int getNumOfSlots() {
3030
return numOfSlots;
3131
}
3232

33-
public void setNumOfSlots(int numOfSlots) {
34-
this.numOfSlots = numOfSlots;
35-
}
33+
// public void setNumOfSlots(int numOfSlots) {
34+
// this.numOfSlots = numOfSlots;
35+
// }
3636

3737
public int getPayAmount() {
3838
return payAmount;
3939
}
4040

41-
public void setPayAmount(int payAmount) {
42-
this.payAmount = payAmount;
43-
}
41+
// public void setPayAmount(int payAmount) {
42+
// this.payAmount = payAmount;
43+
// }
4444

4545
public String getName() {
4646
return name;
4747
}
4848

49-
public void setName(String name) {
50-
this.name = name;
51-
}
49+
// public void setName(String name) {
50+
// this.name = name;
51+
// }
5252

5353
public BuyType getBuyType() {
5454
return buyType;
5555
}
5656

57-
public void setBuyType(BuyType buyType) {
58-
this.buyType = buyType;
59-
}
57+
// public void setBuyType(BuyType buyType) {
58+
// this.buyType = buyType;
59+
// }
6060

6161
public ArrayList<String> getIconList() {
6262
return iconList;
6363
}
6464

65-
public void setIconList(ArrayList<String> iconList) {
66-
this.iconList = iconList;
67-
}
65+
// public void setIconList(ArrayList<String> iconList) {
66+
// this.iconList = iconList;
67+
// }
6868

6969
public int payOut() {
7070
if (buyType.equals(BuyType.DOUBLE_CHANCE)) {
@@ -100,7 +100,7 @@ public int getMoneyNeeded() {
100100
return moneyNeeded;
101101
}
102102

103-
public void setMoneyNeeded(int moneyNeeded) {
104-
this.moneyNeeded = moneyNeeded;
105-
}
103+
// public void setMoneyNeeded(int moneyNeeded) {
104+
// this.moneyNeeded = moneyNeeded;
105+
// }
106106
}

lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/ShawnDunsmore/SlotMachineTest.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.codedifferently.lesson16.ShawnDunsmore;
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
5+
import java.util.ArrayList;
46
import org.junit.jupiter.api.Test;
57

68
public class SlotMachineTest {
@@ -28,10 +30,35 @@ public void testPayAmount_Exists() {
2830
assertEquals(10, slot.getPayAmount());
2931
}
3032

31-
3233
@Test
3334
public void testBuyType_Exists() {
3435
SlotMachine slot = new SlotMachine(1, 10, "Goldie", null, null, 10);
3536
assertEquals(null, slot.getBuyType());
3637
}
38+
39+
@Test
40+
public void testUseDoubleSlots() {
41+
SlotMachine slottwo = new SlotMachine(1, 10, "Goldie", null, null, 10);
42+
SlotMachine slotone = new SlotMachine(1, 10, "Diamond", null, null, 10);
43+
assertEquals(1, slotone.getNumOfSlots());
44+
assertEquals(1, slottwo.getNumOfSlots());
45+
}
46+
47+
@Test
48+
public void testSlotSpin() {
49+
SlotMachine slot = new SlotMachine(1, 10, "Goldie", null, null, 10);
50+
assertEquals(null, slot.getIconList());
51+
}
52+
53+
@Test
54+
public void testPayOut() {
55+
56+
ArrayList<String> icons = new ArrayList<>();
57+
SlotMachine slotMachine1 =
58+
new SlotMachine(1, 10, "Test Slot 1", BuyType.DOUBLE_CHANCE, icons, 10);
59+
assertEquals(20, slotMachine1.payOut(), "Expected payout for DOUBLE_CHANCE to be 20");
60+
61+
SlotMachine slotMachine2 = new SlotMachine(1, 10, "Test Slot 2", BuyType.BONUS_BUY, icons, 10);
62+
assertEquals(30, slotMachine2.payOut(), "Expected payout for BONUS_BUY to be 30");
63+
}
3764
}

0 commit comments

Comments
 (0)