首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件开发 >

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

2012-11-07 
策略模式java源码实现(大话设计模式学习备忘录)/** * h1策略模式/h1 * QS:做个商场收银软件,营销员根

策略模式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);}}

热点排行