CoreJava/exp6/OperationFactory.java

25 lines
418 B
Java
Raw Permalink Normal View History

2024-05-09 09:10:51 +08:00
package exp6;
public class OperationFactory {
public static Operation createOperate(String operate) {
Operation oper = null;
switch(operate) {
case "+":
oper = new OperationAddtion();
break;
case "-":
oper = new OperationSubtraction();
break;
case "*":
oper = new OperationMultiplication();
break;
case "/":
oper = new OperationDivision();
break;
}
return oper;
}
}