Skip to content

Commit 35ab282

Browse files
committed
refactoring out unused methods and public method, moving together
1 parent a295834 commit 35ab282

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

src/vending/VendingMachine.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public void update() {
2929
}
3030

3131
public ArrayList<String> returnCoins() {
32+
setCoinReturnAmount(currentAmount);
3233
returnSlotCoins.addAll(coinList);
3334
coinList.removeAll(coinList);
3435
setCurrentAmount(0.00);
@@ -94,16 +95,13 @@ private void updateDisplay() {
9495
private void updateChangeAmount() {
9596
if (currentAmount >= 1.25) {
9697
setCurrentAmount(currentAmount - 1.25);
97-
coinList.remove(0);
98-
coinList.remove(1);
99-
coinList.remove(2);
10098
}
10199
}
102100

103101
private void setCoinReturnAmount(Double coinReturnAmount) {
104102
this.coinReturnAmount = coinReturnAmount;
105103
}
106-
104+
107105
private void coinAdded(String coin, double coinAmount) {
108106
coinList.add(coin);
109107
coinCalc.insertCoin(coinAmount);

test/vending/VendingMachineTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import java.util.ArrayList;
66

77
import org.junit.Before;
8-
import org.junit.Ignore;
98
import org.junit.Test;
109

1110
public class VendingMachineTests {
@@ -218,7 +217,7 @@ public void machineShouldMakeChangeIfTooMuchMoneyPaidForSoda() {
218217
vendingMachine.sodaButton();
219218
vendingMachine.returnCoins();
220219

221-
assertEquals((Double) QUARTER, vendingMachine.getReturnSlotCoins());
220+
assertEquals((Double) QUARTER, vendingMachine.getCoinReturnAmount());
222221
}
223222

224223
private void insertDollarInQuarters() {

0 commit comments

Comments
 (0)