//欢迎观看者评论
//欢迎观看者评论
//欢迎观看者评论
package Java20131231computer;
import java.util.Scanner;
public class Computer4 {
public static void main(String[] args) {
double numberA,numberB;
int k = 1;
Scanner oper = new Scanner(System.in);
while( k != 0 ){
System.out.println(" 说明: 下面输入两个数字。");
numberA = oper.nextInt();
numberB = oper.nextInt();
System.out.println(" 说明: 下面输入 + - * / 可得到相应的计算");
String str = oper.next();
GetComputerWork getComputerWork = new GetComputerWork(numberA,numberB,str);
getComputerWork.getCaculateWork(numberA, numberB, str);
}
}
}
package Java20131231computer;
public class GetComputerWork {
double numberA, numberB;
String str;
public GetComputerWork() {
super();
// TODO Auto-generated constructor stub
}
public GetComputerWork(double numberA, double numberB, String str) {
super();
this.numberA = numberA;
this.numberB = numberB;
this.str = str;
}
public int getCaculateWork(double numberA,double numberB,String oper){
if(str.equals("+")){
ICaculateFactory ICaculateFactory = new AddCaculateFactory(numberA, numberB);
ICaculateFactory.getCaculate(numberA, numberB).Caculate(numberA, numberB);
return 1;
}
else if(str.equals("-")){
ICaculateFactory ICaculateFactory = new SubtractCaculateFactory(numberA, numberB);
ICaculateFactory.getCaculate(numberA, numberB).Caculate(numberA, numberB);
return 1;
}
else if(str.equals("*")){
ICaculateFactory ICaculateFactory = new MultiplicateCaculateFactory(numberA, numberB);
ICaculateFactory.getCaculate(numberA, numberB).Caculate(numberA, numberB);
return 1;
}
else if(str.equals("/")){
ICaculateFactory ICaculateFactory = new DivideCaculateFactory(numberA, numberB);
ICaculateFactory.getCaculate(numberA, numberB).Caculate(numberA, numberB);
return 1;
}
else {
System.out.println(" 输入无效,操作停止!" );
return 0;
}
}
}
其他的以照片的形式上传