Skip to content

Commit 4668633

Browse files
committed
Step 3: fake it for some inputs
1 parent 18a5dba commit 4668633

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

exercises/tiered_pricing/solutions/mperezi/src/main/java/tv/codely/checkout/TieredPricing.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ public class TieredPricing {
55
private static final double UNIT_PRICE = 299.0;
66

77
public double totalPrice(int subscriptions) {
8-
return subscriptions * UNIT_PRICE;
8+
if (subscriptions < 3) {
9+
return subscriptions * UNIT_PRICE;
10+
}
11+
return 717.0;
912
}
1013
}

exercises/tiered_pricing/solutions/mperezi/src/test/java/tv/codely/checkout/TieredPricingShould.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,13 @@ void returnDoubleTheUnitPriceForTwoSubscriptions() {
2323

2424
assertThat(totalPrice).isEqualTo(598.0);
2525
}
26+
27+
@Test
28+
void returnTripleTheUnitPriceForThreeSubscriptions() {
29+
var tieredPricing = new TieredPricing();
30+
31+
double totalPrice = tieredPricing.totalPrice(3);
32+
33+
assertThat(totalPrice).isEqualTo(717.0);
34+
}
2635
}

0 commit comments

Comments
 (0)