奈學(xué)領(lǐng)域計劃-斬獲名企Offer!一期
class User {
? ?private boolean vip;
? ?public boolean isVip() {
? ? ? ?return vip;
? ?}}class PriceCalculator {
? ?public int calculate(DiscountStrategy discountStrategy, int price, User user) throws IllegalAccessException {
? ? ? ?// 每次新增一種策略就要多加一個類
? ? ? ?return discountStrategy.discount(price, user);
標(biāo)簽: