24.12.2014 Views

Rich Domain Model.pdf

Rich Domain Model.pdf

Rich Domain Model.pdf

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

책임 기반 구현<br />

public abstract class DiscountStrategy {<br />

public Money calculateFee(Showing showing) {<br />

for(Rule each : rules) {<br />

if (each.isStatisfiedBy(showing)) {<br />

return getDiscountedFee(showing);<br />

}<br />

}<br />

}<br />

return showing.getFixedFee();<br />

abstract protected Money getDiscountedFee(Showing showing);<br />

public class AmountDiscountStrategy extends DiscountStrategy {<br />

protected Money getDiscountedFee(Showing showing) {<br />

return showing.getFixedFee().minus(discountAmount);<br />

public class NonDiscountStrategy extends DiscountStrategy {<br />

}<br />

protected Money getDiscountedFee(Showing showing) {<br />

}<br />

public returnclass showing.getFixedFee();<br />

PercentDiscountStrategy extends DiscountStrategy {<br />

} protected Money getDiscountedFee(Showing showing) {<br />

} return showing.getFixedFee().minus(showing.getFixedFee().times(percent));<br />

}<br />

}<br />

38 / 문서의 제목

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!