Skip to content

Commit 72f8958

Browse files
committed
Stashing commit
1 parent 2e32759 commit 72f8958

File tree

3 files changed

+112
-0
lines changed

3 files changed

+112
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.codedifferently.lesson16;
2+
3+
import java.util.ArrayList;
4+
5+
6+
public class GumBallMachine {
7+
8+
enum Colors{
9+
GREEN,
10+
RED,
11+
PINK
12+
}
13+
14+
enum coinTypes{
15+
0.05,
16+
0.10,
17+
0.25
18+
}
19+
20+
private Colors colors;
21+
private int gumBallCount;
22+
private boolean isBroken;
23+
private ArrayList coinType;
24+
private int invalidCoin;
25+
26+
public GumBallMachine(int GumBallCount, boolean isBroken) {
27+
this.colors = colors.GREEN;
28+
this.gumBallCount = gumBallCount;
29+
this.isBroken = isBroken;
30+
this.coinType = coinType;
31+
this.invalidCoin = invalidCoin;
32+
}
33+
34+
public gumBallMachineCount(int gumBallCount) {
35+
if(previousGumballMachine < new GumballMachineCount);{
36+
}
37+
38+
get.GumballCount = new gumballMachineCount;{
39+
}
40+
41+
public int getGumBallCount(){
42+
return new gumBallMachineCount;
43+
}
44+
45+
public Colors getcolors(){
46+
return colors
47+
}
48+
49+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.codedifferently.lesson16;
2+
public class invalidCoinInsertedException extends Exception {
3+
public invalidCoinInsertedException(String message ){
4+
super(message);
5+
}
6+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package com.codedifferently.lesson16;
2+
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
import static org.junit.jupiter.api.Assertions.assertFalse;
5+
import static org.junit.jupiter.api.Assertions.assertNotEquals;
6+
import static org.junit.jupiter.api.Assertions.assertThrows;
7+
import org.junit.jupiter.api.Test;
8+
9+
public class GumballMachineTest {
10+
GumBallMachine testGumBallMachine(20, );
11+
12+
@Test
13+
void testGumballMachineCount() {
14+
//arrange
15+
testGumBallMachine = new gumballMachine();
16+
//act
17+
testGumballMachine.removeGumball();
18+
//assert
19+
assertNotEquals(GumballmachineCount.getGumballCount(),testGumballMachine);
20+
}
21+
22+
@Test
23+
void testGetGumBall() {
24+
// Arrange
25+
var quater = 0.25;
26+
var previousGumBallCount = gumBallMachine.getGumBallCount();
27+
// Act
28+
gumballmachine.getGumBall(quater);
29+
30+
// Assert
31+
assertNotEquals(gumballmachine.getGumBallCount(),previousGumBallCount);
32+
}
33+
@Test
34+
testGumballMachineIsEmpty_whenEmpty() {
35+
// Arrange
36+
37+
38+
// Act
39+
testGumballMachine.getGumBall(threedollars);
40+
41+
// Assert
42+
assertEquals("No more gum! Refill.", testGumballMachine.IsEmpty());
43+
}
44+
@Test
45+
testGetGumBall_InvalidCoinPenny() {
46+
47+
assertThrows (invalidCoinInsertedException.class,()->{
48+
testGumBallMachine.getGumBall(0.01);
49+
});
50+
}
51+
@Test
52+
testGumBallMachineIsBroken(){
53+
testGumBallMachine.IsBroken();
54+
assertFalse(testGumBallMachine.IsBroken);
55+
}
56+
}
57+

0 commit comments

Comments
 (0)