diff --git a/src/Question.java b/src/Question.java new file mode 100644 index 0000000..1d38f6f --- /dev/null +++ b/src/Question.java @@ -0,0 +1,118 @@ +import java.util.Random; + +public class Question { + private int operatorNum; + private int isFenshu; + private String equation; + private String[] num=null; + private String[] ch=null; + public Question() { + this.operatorNum =1; + this.isFenshu = 0; + this.equation=""; + num=new String[5]; + ch=new String[4]; + } + + public void setOperatorNum() { + int a; + Random random=new Random(); + a=random.nextInt(4); + if(a==0){ + operatorNum=++a; + }else if(a==1){ + operatorNum=++a; + }else if(a==2){ + operatorNum=++a; + }else{ + operatorNum=++a; + } + } + public void setIsFenshu(){ + Random random=new Random(); + isFenshu=random.nextInt(2); + } + public String setNum(){ + Random random=new Random(); + if(isFenshu==0){ + return ""+(random.nextInt(25)+1); + } + int a; + int b; + a=random.nextInt(16); + b=random.nextInt(21); + if(a==0){ + a++; + } + if(b==0){ + b+=2; + } + if(b==1){ + b++; + } + for (int i = 2; i <= (a