读书人

谋略模式java源码实现(大话设计模式学

发布时间: 2012-11-07 09:56:10 作者: rapoo

策略模式java源码实现(大话设计模式学习备忘录)


/** * <h1>策略模式</h1> * QS:做个商场收银软件,营销员根据客户所购买的商品和数量向客户收费 第一次程序 * @author xangqun * 改进的程序3(采用策略模式+简单工厂模式) */public class ProgramFive {/** * @param args * @throws IOException  */public static void main(String[] args) throws IOException {System.out.println("单价:");String strA = new BufferedReader(new InputStreamReader(System.in)).readLine();System.out.println("数量:");String strB = new BufferedReader(new InputStreamReader(System.in)).readLine();System.out.println("类型:");String strC = new BufferedReader(new InputStreamReader(System.in)).readLine();CashContextFactory cc=new CashContextFactory(Integer.valueOf(strC));double totalprices=cc.getResult(Double.valueOf(strA)*Double.valueOf(strB));System.out.println(totalprices);}}

读书人网 >软件开发

热点推荐