|
|
|
@ -0,0 +1,120 @@
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
import java.util.Scanner;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
|
|
public class problem {
|
|
|
|
|
String level;
|
|
|
|
|
String name;
|
|
|
|
|
public void display(){
|
|
|
|
|
try {
|
|
|
|
|
new ProcessBuilder("clear").inheritIO().start().waitFor();
|
|
|
|
|
} catch (IOException | InterruptedException e) {
|
|
|
|
|
//e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
// try {
|
|
|
|
|
// Runtime.getRuntime().exec("cmd /c cls").waitFor();
|
|
|
|
|
// } catch (IOException | InterruptedException e) {
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// }
|
|
|
|
|
System.out.println("=== 中小学数学卷子自动生成程序 ===");
|
|
|
|
|
}
|
|
|
|
|
public void start(User user) {
|
|
|
|
|
level = user.level;
|
|
|
|
|
name = user.username;
|
|
|
|
|
while (true) {
|
|
|
|
|
display();
|
|
|
|
|
System.out.println("欢迎你 " + user.username + " " + level);
|
|
|
|
|
System.out.println("输入1开始出题");
|
|
|
|
|
System.out.println("输入2切换出题年级");
|
|
|
|
|
System.out.println("输入-1退出登录,返回开始界面");
|
|
|
|
|
Scanner sc = new Scanner(System.in);
|
|
|
|
|
int flag=0;
|
|
|
|
|
while (true) {
|
|
|
|
|
String str = sc.next();
|
|
|
|
|
try {
|
|
|
|
|
flag=Integer.parseInt(str);
|
|
|
|
|
} catch (NumberFormatException e) {
|
|
|
|
|
flag=0;
|
|
|
|
|
}
|
|
|
|
|
if (flag == 1 || flag ==2 || flag ==-1)
|
|
|
|
|
break;
|
|
|
|
|
else
|
|
|
|
|
System.out.println("请输入正确的操作");
|
|
|
|
|
}
|
|
|
|
|
if (flag == 1) {
|
|
|
|
|
if (f1() == 0)
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (flag == 2) {
|
|
|
|
|
if (f2() == 0)
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (flag == -1)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int f1() {
|
|
|
|
|
System.out.println("正在为" + level + "出题");
|
|
|
|
|
System.out.println("请在10-30的范围内输入出题数目,输入-1返回操作界面");
|
|
|
|
|
Scanner sc = new Scanner(System.in);
|
|
|
|
|
int num=0;
|
|
|
|
|
while (true) {
|
|
|
|
|
String str = sc.next();
|
|
|
|
|
try {
|
|
|
|
|
num=Integer.parseInt(str);
|
|
|
|
|
} catch (NumberFormatException e) {
|
|
|
|
|
num=0;
|
|
|
|
|
}
|
|
|
|
|
if (num == -1)
|
|
|
|
|
break;
|
|
|
|
|
if (num >= 10 && num <= 30)
|
|
|
|
|
break;
|
|
|
|
|
else
|
|
|
|
|
System.out.println("请输入10-30范围的出题数");
|
|
|
|
|
}
|
|
|
|
|
if (num == -1) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
if (level.equals("小学")) {
|
|
|
|
|
Primaryproblem p1 = new Primaryproblem();
|
|
|
|
|
p1.start(num,name);
|
|
|
|
|
} else if (level.equals("初中")) {
|
|
|
|
|
Middleproblem m1 = new Middleproblem();
|
|
|
|
|
m1.start(num,name);
|
|
|
|
|
} else if (level.equals("高中")) {
|
|
|
|
|
Highproblem h1 = new Highproblem();
|
|
|
|
|
h1.start(num,name);
|
|
|
|
|
}
|
|
|
|
|
System.out.println("已出题完成,输入-1返回操作界面");
|
|
|
|
|
while (!sc.next().equals("-1")) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int f2() {
|
|
|
|
|
System.out.println("请输入想要切换的出题年级,输入-1返回操作界面");
|
|
|
|
|
String num;
|
|
|
|
|
Scanner sc = new Scanner(System.in);
|
|
|
|
|
while (true) {
|
|
|
|
|
num = sc.next();
|
|
|
|
|
if (num.equals("-1"))
|
|
|
|
|
break;
|
|
|
|
|
if (num.equals("初中") || (num.equals("小学")) || (num.equals("高中")))
|
|
|
|
|
break;
|
|
|
|
|
else
|
|
|
|
|
System.out.println("请输入小学、初中和高中三个选项中的一个");
|
|
|
|
|
}
|
|
|
|
|
if (num.equals("-1")) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
level = num;
|
|
|
|
|
System.out.println("已成功修改出题年级为" + level + ",输入-1返回操作界面");
|
|
|
|
|
while (!sc.next().equals("-1")) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|