File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
exercises/tiered_pricing/solutions/mperezi/src
main/java/tv/codely/checkout
test/java/tv/codely/checkout Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments