This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Movie { | |
public Money calculateMovieFee(Screening screening) { | |
// 예외적인 케이스를 처리하기 위해 요금 계산 책임을 Movie가 수행 | |
if (discountPolicy == null) | |
return fee; | |
// 기존 방식대로 요금 계산 책임을 discountPolicy가 수행 | |
return fee.minus(discountPolicy.calculateDiscountAmount(screening)); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Something { | |
Parent parent; | |
public Something(Parent parent) { | |
this.parent = parent; | |
} | |
public void doing() { | |
parent.doing(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FixedFeeCondition implements FeeCondition { | |
@Override | |
public List<DateTimeInterval> findTimeINtervals(Call call) { | |
return Arrays.asList(call.getInterval()); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DurationFeeCondition implements FeeCondition { | |
private Duration from; | |
private Duration to; | |
public DurationFeeCondition(Duration from, Duration to) { | |
this.from = from; | |
this.to = to; | |
} | |
@Override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DayOfWeekFeeCondition implements FeeCondition { | |
private List<DayOfWeek> dayOfWeeks = new ArrayList<>(); | |
public DayOfWeekFeeCondition(DayOfWeek ... dayOfWeeks) { | |
this.dayOfWeeks = dayOfWeeks; | |
} | |
@Override | |
public List<DateTimeInterval> findTimeInterval(Call call) { | |
return call.getInterval().splitByDay() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DayOfWeekFeeCondition implements FeeCondition { | |
private List<DayOfWeek> dayOfWeeks = new ArrayList<>(); | |
public DayOfWeekFeeCondition(DayOfWeek ... dayOfWeeks) { | |
this.dayOfWeeks = dayOfWeeks; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TimeOfDayFeeCondition implements FeeCondition { | |
private LocalTime from; | |
private LocalTime to; | |
public TimeOfDayFeeCondition(LocalTime from, LocalTime to) { | |
this.from = from; | |
this.to = to; | |
} | |
@Override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TimeOfDayFeeCondition implements FeeCondition { | |
private LocalTime from; | |
private LocalTime to; | |
public TimeOfDayFeeCondition(LocalTime from, LocalTime to) { | |
this.from = from; | |
this.to = to; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BasicRatePolicy implements RatePolicy { | |
private List<FeeRule> feeRules = new ArrayList<>(); | |
public BasicRatePolicy(FeeRule ... feeRules) { | |
this.feeRules = Arrays.asList(feeRules); | |
} | |
@Override | |
public Money calculateFee(Phone phone) { | |
return phone.getCalls() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FeePerDuration { | |
private Money fee; | |
private Duration duration; | |
public FeePerDuration(Money fee, Duration duration) { | |
this.fee = fee; | |
this.duration = duration; | |
} | |
public Money calculate(DateTimeInterval interval) { |
NewerOlder