Skip to content

Commit bf50497

Browse files
committed
Add fourth tier
1 parent 1518821 commit bf50497

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ public class TieredPricing {
77
private enum Tier {
88
FIRST(299.0, 1, 2),
99
SECOND(239.0, 3, 10),
10-
THIRD(219.0, 11, 25);
10+
THIRD(219.0, 11, 25),
11+
FOURTH(199.0, 26, 50);
1112

1213
final double unitPrice;
1314
final int startRange;

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ void returnTotalPriceForThirdTier(int subscriptions) {
4242
assertThat(totalPrice).isEqualTo(subscriptions * 219.0);
4343
}
4444

45+
@ParameterizedTest
46+
@MethodSource("rangeFourthTier")
47+
void returnTotalPriceForFourthTier(int subscriptions) {
48+
double totalPrice = tieredPricing.totalPrice(subscriptions);
49+
50+
assertThat(totalPrice).isEqualTo(subscriptions * 199.0);
51+
}
52+
4553
private static Stream<Integer> rangeFirstTier() {
4654
return IntStream.rangeClosed(1, 2).boxed();
4755
}
@@ -53,4 +61,8 @@ private static Stream<Integer> rangeSecondTier() {
5361
private static Stream<Integer> rangeThirdTier() {
5462
return IntStream.rangeClosed(11, 25).boxed();
5563
}
64+
65+
private static Stream<Integer> rangeFourthTier() {
66+
return IntStream.rangeClosed(26, 50).boxed();
67+
}
5668
}

0 commit comments

Comments
 (0)