You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
483 B
13 lines
483 B
package 依赖关系;
|
|
|
|
public class DiscountStrategyTest {
|
|
public static void main(String[] args) {
|
|
DiscountStrategy fixed = new FixedAmountDiscount();
|
|
DiscountStrategy percent = new PercentageDiscount();
|
|
|
|
double amount = 80.0;
|
|
System.out.println("Amount: " + amount);
|
|
System.out.println("Fixed discount: " + fixed.calculateDiscount(amount));
|
|
System.out.println("Percentage discount: " + percent.calculateDiscount(amount));
|
|
}
|
|
} |