Question: How do you achieve the functions of calculator by Object-Oriented ? Analysis: 1,The function of calculator consists of 4 basic operations:Plus, Substraction, Multify, Division. Generally speaking, we can put the 4 operations into one Java c…
public class Test { public static void main(String[] args){ try{ Factory.factory("A").doSth(); Factory.factory("B").doSth(); Factory.factory("C").doSth(); }catch(BadProductException e){ e.printStackTrace(); } } } class Factor…
原文链接:http://www.c-sharpcorner.com/UploadFile/19b1bd/design-patterns-simplified-part3-factory/ Design Patterns Simplified - Part 3 (Simple Factory)[设计模式简述--第三部分(简单工厂)] This article explains why and how to use the Simple Factory Design Pattern in softw…