Skip to content

Commit bd3d83a

Browse files
committed
Step 4: fake it again for the new tier
1 parent def4aeb commit bd3d83a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ public class TieredPricing {
44

55
private static final double FIRST_TIER_UNIT_PRICE = 299.0;
66
private static final double SECOND_TIER_UNIT_PRICE = 239.0;
7+
public static final double THIRD_TIER_UNIT_PRICE = 219.0;
78

89
public double totalPrice(int subscriptions) {
910
if (subscriptions < 3) {
1011
return subscriptions * FIRST_TIER_UNIT_PRICE;
1112
}
12-
return subscriptions * SECOND_TIER_UNIT_PRICE;
13+
if (subscriptions < 11) {
14+
return subscriptions * SECOND_TIER_UNIT_PRICE;
15+
}
16+
return subscriptions * THIRD_TIER_UNIT_PRICE;
1317
}
1418
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,11 @@ void returnTripleTheSecondTierUnitPriceForThreeSubscriptions() {
3434

3535
assertThat(totalPrice).isEqualTo(717.0);
3636
}
37+
38+
@Test
39+
void returnElevenTimesTheThirdTierUnitPriceForElevenSubscriptions() {
40+
double totalPrice = tieredPricing.totalPrice(11);
41+
42+
assertThat(totalPrice).isEqualTo(2409.0);
43+
}
3744
}

0 commit comments

Comments
 (0)