tdd-java-demo
tdd java demo with micro-commits
git clone https://9o.is/git/tdd-java-demo.git
commit f56dc2e5f23e5f48230ee73250a314a4da52c4f0 parent bbcb174202cff64f5b24376e5c53682a7c982a19 Author: Jul <jul@9o.is> Date: Wed, 31 Mar 2021 15:45:45 +0800 extract method getTotal Diffstat:
| M | src/main/java/takehome/Runner.java | | | 6 | +++++- |
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/main/java/takehome/Runner.java b/src/main/java/takehome/Runner.java @@ -20,9 +20,13 @@ public class Runner { double cost = 0.65; out.println("How much " + name + "?"); int amount = in.nextInt(); - double total = amount * cost; + double total = getTotal(cost, amount); DecimalFormat df = new DecimalFormat("0.00"); out.println("Total: $" + df.format(total)); } + + private double getTotal(double cost, int amount) { + return amount * cost; + } }