/**
-
学生,折扣策略:打八折。
-
@author zhangfly
*/
public class StudentDiscountStrategy implements DiscountStrategy {
@Override
public double getDiscountPrice(double value) {
return value * 0.8;
}
}
/**
-
VIP,电影票折扣策略半价。
-
@author zhangfly
*/
public class VIPDiscountStrategy implements DiscountStrategy {
@Override
public double getDiscountPrice(double value) {
return value * 0.5;
}
}
public class Test {
public Test() {
double price = 100;
MovieTicket movieTicket = new MovieTicket();
movieTicket.setPrice(price);
System.out.println("电影票原价: " + movieTicket.getPrice());
DiscountStrategy studentStrategy