小碼哥深入Node.js技術(shù)棧
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)簽: