網易云課堂Java高級架構師第7期
class Discount95Strategy extends DiscountStrategy {
? ?@Override
? ?public int discount(int price, User user) {
? ? ? ?return (int) (price * 0.95);
? ?}}class VipDiscountStrategy extends DiscountStrategy {
? ?@Override
? ?public int discount(int price, User user) {
? ? ? ?if (user.isVip()) {
? ? ? ? ? ?return (int) (price * 0.85);
? ? ? ?}
? ? ? ?return (int) (price * 0.95);
? ?}
標簽: