tdd-java-demo
tdd java demo with micro-commits
git clone https://9o.is/git/tdd-java-demo.git
commit 99e6f8ba19f4ad9639451be6123273f87467d350 parent ff2a094031ebcbb33008b6c24de8805fd936d057 Author: Jul <jul@9o.is> Date: Wed, 31 Mar 2021 17:50:03 +0800 introduce variable discount Diffstat:
| M | src/main/java/takehome/Runner.java | | | 4 | +++- |
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/main/java/takehome/Runner.java b/src/main/java/takehome/Runner.java @@ -29,8 +29,10 @@ public class Runner { double total = basket.getTotal(); Item apple = items[3]; + double discount = 0; double amount = basket.getAmounts().get(apple); - if (amount > 0) total -= 0.01; + if (amount > 0) discount = 0.01; + total -= discount; DecimalFormat df = new DecimalFormat("0.00"); out.println("Total: $" + df.format(total));