CoreJava/exp6/OperationFactory.java
2024-05-09 09:10:51 +08:00

25 lines
418 B
Java

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;
}
}