java 代码重构-第一章(使用策略模式,把恶心的switch代码去掉...) 一
?
上一篇文章:java 代码重构-第一章(终于…我们来到继承(Inheritance))
下一篇文章:java 代码重构-第一章(使用策略模式,把恶心的switch代码去掉...) 二
?
现在我加入新class,并在Price 对象中提供「与型别相依的行为」。为了实现这一点,我在Price 内加入一个抽象函数(abstract method ),并在其所有subclasses 中加上对应的具体函数(concrete method):
首先我创建一个类
Price
?
Rental Record for oyhk 少林足球6.0大话西游1.5Amount owed is 7.5You earned 3 frequent renter points------------------------------------------------<H1>Rentals for <EM>oyhk</EM></ H1><P>少林足球: 6.0<BR>大话西游: 1.5<BR><P>You owe <EM>7.5</EM><P>On this rental you earned <EM>3</EM> frequent renter points<P>?
?