teststrategepattern.java
来自「第四次作业 1、 创建一个Animal(动物)类」· Java 代码 · 共 31 行
JAVA
31 行
/**
* use strategy pattern to get price of different books
*
*
*/
public class TestStrategePattern {
private static void getDetails(BookCount book){//use polymorphism
System.out.println("Book " +book.getClass().getName()+"'s price is "+book.getPrice());
System.out.println("Book "+book.getClass().getName() +"'s account is "+book.getAccount());
System.out.println("Book "+book.getClass().getName()+" is sold at price "+book.getBookPrice());
}
public static void main(String[] args) {
// TODO Auto-generated method stub
ABook a = new ABook(0.8,120);
BBook b = new BBook(0.9,100);
CBook c = new CBook(0.7,32);
getDetails(a);
getDetails(b);
getDetails(c);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?