commit
1b3e5097d3
@ -0,0 +1,55 @@
|
||||
# 编译后的类文件
|
||||
*.class
|
||||
|
||||
# 打包文件
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
# IDE 文件
|
||||
/.idea/
|
||||
/.settings/
|
||||
/*.iml
|
||||
/*.ipr
|
||||
/*.iws
|
||||
|
||||
# 构建工具目录
|
||||
/target/
|
||||
/build/
|
||||
/out/
|
||||
|
||||
# 日志文件
|
||||
*.log
|
||||
|
||||
# 系统文件
|
||||
.DS_Store
|
||||
Thumbs.db### IntelliJ IDEA ###
|
||||
out/
|
||||
!**/src/main/**/out/
|
||||
!**/src/test/**/out/
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
bin/
|
||||
!**/src/main/**/bin/
|
||||
!**/src/test/**/bin/
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Main-Class: Main
|
||||
Class-Path: .
|
||||
@ -0,0 +1,3 @@
|
||||
李四1 123
|
||||
李四2 123
|
||||
李四3 123
|
||||
@ -0,0 +1,3 @@
|
||||
张三1 123
|
||||
张三2 123
|
||||
张三3 123
|
||||
@ -0,0 +1,60 @@
|
||||
1、tan13+56✖31=
|
||||
|
||||
2、sin100✖14+√79=
|
||||
|
||||
3、sin17✖68✖cos87+√92+24=
|
||||
|
||||
4、tan42+82-94✖cos89÷tan82=
|
||||
|
||||
5、cos58✖100=
|
||||
|
||||
6、tan99✖31-76=
|
||||
|
||||
7、tan50✖98=
|
||||
|
||||
8、tan96÷52=
|
||||
|
||||
9、sin89=
|
||||
|
||||
10、sin33✖23=
|
||||
|
||||
11、cos22✖27+1=
|
||||
|
||||
12、sin2✖67=
|
||||
|
||||
13、tan89-97-83÷tan16=
|
||||
|
||||
14、sin48-75=
|
||||
|
||||
15、tan51✖69✖83=
|
||||
|
||||
16、cos83-21-21÷44=
|
||||
|
||||
17、sin1+95-sin15=
|
||||
|
||||
18、cos64÷60÷9=
|
||||
|
||||
19、tan92÷12✖41=
|
||||
|
||||
20、tan27+17+4+√64-sin57=
|
||||
|
||||
21、cos7+100÷19÷54=
|
||||
|
||||
22、cos68=
|
||||
|
||||
23、sin52=
|
||||
|
||||
24、tan57÷4✖8+√55=
|
||||
|
||||
25、cos41=
|
||||
|
||||
26、tan30-11+41=
|
||||
|
||||
27、sin100+38✖cos60+√30+62=
|
||||
|
||||
28、cos2÷45-67-72÷tan96=
|
||||
|
||||
29、sin87✖15=
|
||||
|
||||
30、tan48✖58÷26+√92=
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
1、sin20=
|
||||
|
||||
2、cos83÷43+87=
|
||||
|
||||
3、sin98=
|
||||
|
||||
4、cos31-52+77+72-sin68=
|
||||
|
||||
5、sin37-84-sin40-sin50÷82=
|
||||
|
||||
6、cos75÷63÷60=
|
||||
|
||||
7、cos50+7✖24=
|
||||
|
||||
8、tan77-8-6=
|
||||
|
||||
9、tan98÷80+9✖cos99÷tan76=
|
||||
|
||||
10、tan99✖9÷9-sin58=
|
||||
|
||||
11、tan61-93-41=
|
||||
|
||||
12、sin67=
|
||||
|
||||
13、cos51÷31-35=
|
||||
|
||||
14、tan40÷52+47✖cos83=
|
||||
|
||||
15、cos25+10=
|
||||
|
||||
16、cos27÷18-96+72+√86=
|
||||
|
||||
17、sin97÷54+√9+√4-33=
|
||||
|
||||
18、sin25+42÷tan89=
|
||||
|
||||
19、cos48+91=
|
||||
|
||||
20、cos22+18+70=
|
||||
|
||||
@ -0,0 +1,44 @@
|
||||
1、cos27=
|
||||
|
||||
2、sin45✖33=
|
||||
|
||||
3、cos88÷83✖20+88=
|
||||
|
||||
4、tan79-70=
|
||||
|
||||
5、sin6=
|
||||
|
||||
6、sin49+24-sin73=
|
||||
|
||||
7、tan90÷51✖90-sin33=
|
||||
|
||||
8、sin75✖93✖cos10+√4✖47=
|
||||
|
||||
9、sin90÷89+√56-sin39+5=
|
||||
|
||||
10、tan8+34+25÷tan19=
|
||||
|
||||
11、sin37=
|
||||
|
||||
12、cos90+92✖59=
|
||||
|
||||
13、sin62✖29+√24+√43+80=
|
||||
|
||||
14、sin74✖87=
|
||||
|
||||
15、cos47✖34=
|
||||
|
||||
16、sin99✖74-sin77÷tan3+86=
|
||||
|
||||
17、cos96÷45+76✖72=
|
||||
|
||||
18、sin38-83-sin86÷tan99-30=
|
||||
|
||||
19、sin48-19✖cos92-sin8✖22=
|
||||
|
||||
20、cos71+14=
|
||||
|
||||
21、cos24✖68÷85=
|
||||
|
||||
22、tan100÷64=
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
王五1 123
|
||||
王五2 123
|
||||
王五3 123
|
||||
@ -0,0 +1,97 @@
|
||||
import teacher.JuniorTeacher;
|
||||
import teacher.PrimaryTeacher;
|
||||
import teacher.SeniorTeacher;
|
||||
import teacher.Teacher;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Main {
|
||||
static List<String> primary = Arrays.asList("张三1 123", "张三2 123", "张三3 123");
|
||||
static List<String> junior = Arrays.asList("李四1 123", "李四2 123", "李四3 123");
|
||||
static List<String> senior = Arrays.asList("王五1 123", "王五2 123", "王五3 123");
|
||||
|
||||
static boolean log1(String bookName, String password) {
|
||||
if (bookName.matches(".*小学.*") && primary.contains(password)) {
|
||||
return true;
|
||||
} else if (bookName.matches(".*初中.*") && junior.contains(password)) {
|
||||
return true;
|
||||
} else return bookName.matches(".*高中.*") && senior.contains(password);
|
||||
}
|
||||
|
||||
static boolean log(String bookName, String password) {
|
||||
try (BufferedReader fr = new BufferedReader(new FileReader(bookName))) {
|
||||
String line;
|
||||
while ((line = fr.readLine()) != null) {
|
||||
if (line.equals(password)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} catch (IOException e) {
|
||||
return log1(bookName, password);
|
||||
}
|
||||
}
|
||||
|
||||
static void generate(Teacher teacher) {
|
||||
Scanner sc = new Scanner(System.in);
|
||||
while (true) {
|
||||
teacher.initMode();
|
||||
String line = sc.nextLine();
|
||||
int number;
|
||||
if (line.matches("-?\\d+")) {
|
||||
try {
|
||||
number = Integer.parseInt(line);
|
||||
} catch (NumberFormatException n) {
|
||||
number = 40;
|
||||
}
|
||||
if (number == -1) {
|
||||
return;
|
||||
} else if (number >= 10 && number <= 30) {
|
||||
teacher.generatePaper(number);
|
||||
} else {
|
||||
System.out.println("请输入10-30以内的数字");
|
||||
}
|
||||
} else if (line.equals("切换为小学")) {
|
||||
teacher = new PrimaryTeacher(teacher.userName);
|
||||
} else if (line.equals("切换为初中")) {
|
||||
teacher = new JuniorTeacher(teacher.userName);
|
||||
} else if (line.equals("切换为高中")) {
|
||||
teacher = new SeniorTeacher(teacher.userName);
|
||||
} else {
|
||||
System.out.println("请输入有效的数字或指令!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Scanner sc = new Scanner(System.in);
|
||||
System.out.println("请输入用户名和密码,两者之间用一个空格隔开");
|
||||
String s;
|
||||
while (sc.hasNextLine()) {
|
||||
s = sc.nextLine();
|
||||
if (s.matches("\\s*")) {
|
||||
System.out.println("输入不能为空!");
|
||||
} else {
|
||||
String name = s.split(" ")[0];
|
||||
if (log("./doc/小学老师账号密码本", s)) {
|
||||
Teacher teacher = new PrimaryTeacher(name);
|
||||
generate(teacher);
|
||||
} else if (log("./doc/初中老师账号密码本", s)) {
|
||||
Teacher teacher = new JuniorTeacher(name);
|
||||
generate(teacher);
|
||||
} else if (log("./doc/高中老师账号密码本", s)) {
|
||||
Teacher teacher = new SeniorTeacher(name);
|
||||
generate(teacher);
|
||||
} else {
|
||||
System.out.println("请输入正确的用户名、密码:");
|
||||
}
|
||||
}
|
||||
System.out.println("请输入用户名和密码,两者之间用一个空格隔开");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package paper;
|
||||
|
||||
import problem.JuniorMathProblem;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class JuniorPaper extends Paper {
|
||||
public JuniorPaper(int problemNumber, String teacherName) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
|
||||
String formattedDate = "./doc/" + teacherName + "/" + sdf.format(new Date()) + ".txt";
|
||||
File file = new File(formattedDate);
|
||||
try {
|
||||
if (!file.exists()) {
|
||||
checkPath(file);
|
||||
} else {
|
||||
file.createNewFile();
|
||||
}
|
||||
FileOutputStream fos = new FileOutputStream(file, true);
|
||||
OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
|
||||
BufferedWriter bw = new BufferedWriter(osw);
|
||||
for (int i = 1; i <= problemNumber; i++) {
|
||||
JuniorMathProblem pmp = new JuniorMathProblem();
|
||||
if (pmp.examine(teacherName)) {
|
||||
String line = String.valueOf(i) + "、" + pmp.content;
|
||||
bw.write(line);
|
||||
bw.newLine();
|
||||
bw.newLine();
|
||||
} else {
|
||||
i--;
|
||||
}
|
||||
}
|
||||
bw.close();
|
||||
System.out.println("已完成出题。");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package paper;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public abstract class Paper {
|
||||
protected void checkPath(File file) throws IOException {
|
||||
if (!file.exists()) {
|
||||
Path filePath = Paths.get(file.getPath());
|
||||
Files.createDirectories(filePath.getParent());
|
||||
Files.createFile(filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package paper;
|
||||
|
||||
import problem.PrimaryMathProblem;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class PrimaryPaper extends Paper {
|
||||
public PrimaryPaper(int problemNumber, String teacherName) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
|
||||
String formattedDate = "./doc/" + teacherName + "/" + sdf.format(new Date()) + ".txt";
|
||||
File file = new File(formattedDate);
|
||||
try {
|
||||
if (!file.exists()) {
|
||||
checkPath(file);
|
||||
} else {
|
||||
file.createNewFile();
|
||||
}
|
||||
BufferedWriter bw = new BufferedWriter(new FileWriter(file, true));
|
||||
for (int i = 1; i <= problemNumber; i++) {
|
||||
PrimaryMathProblem pmp = new PrimaryMathProblem();
|
||||
if (pmp.examine(teacherName)) {
|
||||
String line = String.valueOf(i) + "、" + pmp.content;
|
||||
bw.write(line);
|
||||
bw.newLine();
|
||||
bw.newLine();
|
||||
} else {
|
||||
i--;
|
||||
}
|
||||
}
|
||||
bw.close();
|
||||
System.out.println("已完成出题。");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package paper;
|
||||
|
||||
import problem.SeniorMathProblem;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class SeniorPaper extends Paper {
|
||||
public SeniorPaper(int problemNumber, String teacherName) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
|
||||
String formattedDate = "./doc/" + teacherName + "/" + sdf.format(new Date()) + ".txt";
|
||||
File file = new File(formattedDate);
|
||||
try {
|
||||
if (!file.exists()) {
|
||||
checkPath(file);
|
||||
} else {
|
||||
file.createNewFile();
|
||||
}
|
||||
FileOutputStream fos = new FileOutputStream(file, true);
|
||||
OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
|
||||
BufferedWriter bw = new BufferedWriter(osw);
|
||||
for (int i = 1; i <= problemNumber; i++) {
|
||||
SeniorMathProblem pmp = new SeniorMathProblem();
|
||||
if (pmp.examine(teacherName)) {
|
||||
String line = String.valueOf(i) + "、" + pmp.content;
|
||||
bw.write(line);
|
||||
bw.newLine();
|
||||
bw.newLine();
|
||||
} else {
|
||||
i--;
|
||||
}
|
||||
}
|
||||
bw.close();
|
||||
System.out.println("已完成出题。");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package problem;
|
||||
|
||||
public abstract class MathProblem {
|
||||
public String content = "";
|
||||
public String[] op2 = {"+", "-", "✖", "÷"};
|
||||
|
||||
boolean examine(String teacherName) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,77 @@
|
||||
package problem;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.Random;
|
||||
|
||||
public class SeniorMathProblem extends MathProblem {
|
||||
String[] opFront = {"√", "sin", "cos", "tan"};
|
||||
|
||||
public SeniorMathProblem() {
|
||||
// 生成高中题的函数
|
||||
Random random = new Random();
|
||||
int total = random.nextInt(5) + 1;
|
||||
if (total == 1) {
|
||||
int op = random.nextInt(3);
|
||||
int number = random.nextInt(100) + 1;
|
||||
if (op == 0) {
|
||||
content = "sin" + String.valueOf(number);
|
||||
} else if (op == 1) {
|
||||
content = "cos" + String.valueOf(number);
|
||||
} else {
|
||||
content = "tan" + String.valueOf(number);
|
||||
}
|
||||
} else {
|
||||
int[] number = new int[total];
|
||||
number[0] = random.nextInt(100) + 1;
|
||||
int choice = random.nextInt(3);
|
||||
if (choice == 0) {
|
||||
content = "sin" + String.valueOf(number[0]);
|
||||
} else if (choice == 1) {
|
||||
content = "tan" + String.valueOf(number[0]);
|
||||
} else {
|
||||
content = "cos" + String.valueOf(number[0]);
|
||||
}
|
||||
for (int i = 1; i < total; i++) {
|
||||
number[i] = random.nextInt(100) + 1;
|
||||
int op = random.nextInt(4);
|
||||
if (i == choice + 2 || i == choice + 3) {
|
||||
content += op2[op] + opFront[op] + String.valueOf(number[i]);
|
||||
} else {
|
||||
content += op2[op] + String.valueOf(number[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
content += "=";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean examine(String teacherName) {
|
||||
try {
|
||||
File folder = new File("./doc/" + teacherName);
|
||||
if (!folder.exists() || !folder.isDirectory()) {
|
||||
System.out.println("文件夹不存在或不是目录!");
|
||||
}
|
||||
File[] files = folder.listFiles();
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
if (file.isFile()) {
|
||||
BufferedReader fr = new BufferedReader(new FileReader(file));
|
||||
String line;
|
||||
while ((line = fr.readLine()) != null) {
|
||||
if (line.equals(content)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
fr.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package teacher;
|
||||
|
||||
import paper.Paper;
|
||||
|
||||
public abstract class Teacher {
|
||||
enum rank {
|
||||
PRIMARY,
|
||||
JUNIOR,
|
||||
SENIOR
|
||||
}
|
||||
|
||||
public String mode = "";
|
||||
public String userName = "";
|
||||
public Paper paper;
|
||||
|
||||
public void initMode() {}
|
||||
|
||||
public void generatePaper(int number) {}
|
||||
}
|
||||
Loading…
Reference in new issue