java面向物件計算器
阿新 • • 發佈:2019-01-05
public static void main(String[] args) {
// Operation oper;
// oper=OperationFactory.createOperate('+');
// System.out.println("請輸入_numberA:");
// Scanner s = new Scanner(System.in);
// oper.setNumberA(s.nextDouble());
// System.out.println("請輸入_numberB:");
// oper.setNumberB(s.nextDouble());
// double result = oper.getResult();
// System.out.println("結果是:"+result);
//
// Operation oper;
// Scanner s = new Scanner(System.in);
// System.out.println("請輸入運算子(+ - * /):");
// String operChar = s.next();
// switch(operChar){
// case "+" : oper = new OperationAdd();
// case "-" : oper = new OperationSub();
// case "*" : oper = new OperationMul();
// case "/" : oper = new OperationDiv();
// default:
// oper = new OperationAdd();
// }
// System.out.println("請輸入_numberA:");
// oper.setNumberA(s.nextDouble());
// System.out.println("請輸入_numberB:");
// oper.setNumberB(s.nextDouble());
// double result = oper.getResult();
// System.out.println("計算結果是:"+result);
// s.close();
//
// System.out.println("請輸入_numberA:");
// Scanner s = new Scanner(System.in);
// int num1 = s.nextInt();
// System.out.println("請輸入_numberB:");
// int num2 = s.nextInt();
// System.out.println("請輸入運算子(+ - * /):");
// String oper = s.next();
// switch(oper){
// case "+" : System.out.println(num1+num2);
// case "-" : System.out.println(num1-num2);
// case "*" : System.out.println(num1*num2);
// case "/" : System.out.println(num1/num2);
// case "%" : System.out.println(num1%num2);
// }
}
// Operation oper;
// oper=OperationFactory.createOperate('+');
// System.out.println("請輸入_numberA:");
// Scanner s = new Scanner(System.in);
// oper.setNumberA(s.nextDouble());
// System.out.println("請輸入_numberB:");
// oper.setNumberB(s.nextDouble());
// double result = oper.getResult();
// System.out.println("結果是:"+result);
//
// Operation oper;
// Scanner s = new Scanner(System.in);
// System.out.println("請輸入運算子(+ - * /):");
// String operChar = s.next();
// switch(operChar){
// case "+" : oper = new OperationAdd();
// case "-" : oper = new OperationSub();
// case "*" : oper = new OperationMul();
// case "/" : oper = new OperationDiv();
// default:
// oper = new OperationAdd();
// }
// System.out.println("請輸入_numberA:");
// oper.setNumberA(s.nextDouble());
// System.out.println("請輸入_numberB:");
// oper.setNumberB(s.nextDouble());
// double result = oper.getResult();
// System.out.println("計算結果是:"+result);
// s.close();
//
// System.out.println("請輸入_numberA:");
// Scanner s = new Scanner(System.in);
// int num1 = s.nextInt();
// System.out.println("請輸入_numberB:");
// int num2 = s.nextInt();
// System.out.println("請輸入運算子(+ - * /):");
// String oper = s.next();
// switch(oper){
// case "+" : System.out.println(num1+num2);
// case "-" : System.out.println(num1-num2);
// case "*" : System.out.println(num1*num2);
// case "/" : System.out.println(num1/num2);
// case "%" : System.out.println(num1%num2);
// }
}