import java.util.Scanner; /** * * @author Алла */ public class Calculator { Scanner in = new Scanner(System.in); private OperationFactory operationFactory; public Calculator(OperationFactory operationFactory) { this.operationFactory = operationFactory; } public void exec() { while (true) { System.out.println("Aргумент 1:"); double arg1 = Double.parseDouble(in.nextLine()); System.out.println("Операция:"); String op = in.nextLine(); System.out.println("Aргумент 2:"); double arg2 = Double.parseDouble(in.nextLine()); double result = operationFactory.getOpInstance(op).exec(arg1, arg2); System.out.println("Результат:" + result); } } public static void main(String[] args) { MyOpFactory operationFactory = new MyOpFactory(); Calculator calculator = new Calculator(operationFactory); calculator.exec(); } }