File tree 2 files changed +15
-1
lines changed
Company_based_Qs/Thoughtworks/CodePairing_Sample_CodeBase/app/src/main/java/org/example
2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,10 @@ public double calculateTotal() {
27
27
28
28
public double applyDiscount () {
29
29
double total = calculateTotal ();
30
- if (user .getUserType ().equalsIgnoreCase ("premium" )) {
30
+ if (user .getUserType ().equalsIgnoreCase ("super premium" )) {
31
+ System .out .println ("Applying 30% discount for super premium user." );
32
+ return total * 0.70 ;
33
+ } else if (user .getUserType ().equalsIgnoreCase ("premium" )) {
31
34
System .out .println ("Applying 20% discount for premium user." );
32
35
return total * 0.80 ;
33
36
} else {
Original file line number Diff line number Diff line change @@ -16,6 +16,9 @@ public static void main(String[] args) {
16
16
User regularUser = new User ("Alice" , "regular" );
17
17
User premiumUser = new User ("Bob" , "premium" );
18
18
19
+ // NEW: create a super premium user
20
+ User superPremiumUser = new User ("Chris" , "super premium" );
21
+
19
22
// Create some products
20
23
Product product1 = new Product ("Laptop" , 1000 );
21
24
Product product2 = new Product ("Headphones" , 200 );
@@ -33,5 +36,13 @@ public static void main(String[] args) {
33
36
premiumCart .addProduct (product1 );
34
37
premiumCart .addProduct (product2 );
35
38
premiumCart .checkout (); // Should apply a 20% discount
39
+
40
+ System .out .println ("" );
41
+
42
+ // NEW: create a cart for a super premium user
43
+ Cart superPremiumCart = new Cart (superPremiumUser );
44
+ superPremiumCart .addProduct (product1 );
45
+ superPremiumCart .addProduct (product2 );
46
+ superPremiumCart .checkout (); // Should apply a 20% discount
36
47
}
37
48
}
You can’t perform that action at this time.
0 commit comments