mirror of
https://github.com/This-weiyuqing/javaAutoScore.git
synced 2026-10-18 03:03:42 +08:00
Initial commit
This commit is contained in:
commit
ada5d75de7
27 files changed
+491
No files matched your search
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2020 魏遇卿 All Rights Reserved.
|
||||
* FileName: asdf.java
|
||||
* @author: 魏遇卿@date: 2020/6/11 下午4:50@version: 1.0
|
||||
* E-mail:358614401@qq.com
|
||||
* Code with UTF-8
|
||||
*/
|
||||
|
||||
package autoScore;
|
||||
import autoScore.userIn;
|
||||
import autoScore.*;
|
||||
public class mainDo{
|
||||
public static void main(String[] args) {
|
||||
mainGUI gui=new mainGUI();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (c) 2020 魏遇卿 All Rights Reserved.
|
||||
* FileName: asdf.java
|
||||
* @author: 魏遇卿@date: 2020/6/11 下午4:50@version: 1.0
|
||||
* E-mail:358614401@qq.com
|
||||
* Code with UTF-8
|
||||
*/
|
||||
|
||||
package autoScore;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class mainGUI extends JFrame implements ActionListener {
|
||||
private JTextField question;
|
||||
private JButton A,B,C,D;
|
||||
Container c;//创建主容器
|
||||
//构造方法
|
||||
public mainGUI(){
|
||||
//创建窗口容器
|
||||
super("Auto score to exam");
|
||||
/* this.setBounds(100,100,100,100);*/
|
||||
//获取主容器并设置为网格组布局
|
||||
c=this.getContentPane();
|
||||
c.setLayout(null);
|
||||
this.setVisible(true);
|
||||
this.setSize(900,300);//设置窗口大小
|
||||
this.setResizable(false);//设置窗口固定大小
|
||||
this.setLocationRelativeTo(null);//设置窗口居中
|
||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//设置默认关闭操作
|
||||
|
||||
//网格组布局管理器
|
||||
|
||||
//创建问题显示位置
|
||||
JLabel questionStudent = new JLabel("这是问题的位置andFuckJavaGUI");
|
||||
GridBagLayout questtionText = new GridBagLayout();
|
||||
questionStudent.setBounds(0,0,900,200);
|
||||
questionStudent.setText("fuckJavaGUI");//更改标签内容
|
||||
this.add(questionStudent);
|
||||
//字体
|
||||
questionStudent.setFont(new Font("微软雅黑",Font.BOLD,20));
|
||||
|
||||
// setLayout(null);
|
||||
|
||||
A = new JButton("A");
|
||||
A.addActionListener(this);
|
||||
this.add(A);
|
||||
A.setBounds(100, 200, 100, 50);
|
||||
|
||||
B = new JButton("B");
|
||||
this.add(B);
|
||||
B.addActionListener(this);
|
||||
B.setBounds(300, 200, 100, 50);
|
||||
|
||||
C = new JButton("C");
|
||||
this.add(C);
|
||||
C.addActionListener(this);
|
||||
C.setBounds(500, 200, 100, 50);
|
||||
|
||||
D = new JButton("D");
|
||||
D.addActionListener(this);
|
||||
this.add(D);
|
||||
D.setBounds(700, 200, 100, 50);
|
||||
}
|
||||
|
||||
/*private class panelABCD extends JPanel implements ActionListener{
|
||||
|
||||
}*/
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(e.getActionCommand().equals("A")){
|
||||
// return "A";
|
||||
}
|
||||
if (e.getActionCommand().equals("B")){
|
||||
// return "B";
|
||||
}
|
||||
if (e.getActionCommand().equals("B")){
|
||||
// return "C";
|
||||
}
|
||||
if (e.getActionCommand().equals("B")){
|
||||
// return "D";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/*public static void main(String[] args) {
|
||||
mainGUI mainGUI= new mainGUI();
|
||||
}*/
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package autoScore;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class question {
|
||||
public static File question(int i) {
|
||||
File srcFile = new File("D:\\WindowsCToD\\fire\\GeneticsMultipleChoice\\Question");
|
||||
File[] fileArr = srcFile.listFiles();
|
||||
//System.out.println(fileArr[i]);
|
||||
return fileArr[i];
|
||||
}
|
||||
|
||||
/* public static void questiontext() {
|
||||
File fireName=question(0);
|
||||
InputStream in;
|
||||
InputStreamReader reader=new InputStreamReader(new FileInputStream(fireName));
|
||||
}*/
|
||||
public static void readFile() {
|
||||
File pathname = question(0);
|
||||
try (FileReader reader = new FileReader(pathname);
|
||||
BufferedReader br = new BufferedReader(reader) // 建立一个对象,它把文件内容转成计算机能读懂的语言
|
||||
) {
|
||||
String line;
|
||||
//网友推荐更加简洁的写法
|
||||
while ((line = br.readLine()) != null) {
|
||||
// 一次读入一行数据
|
||||
System.out.println(line);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
question(0);
|
||||
System.out.println(question(0));
|
||||
readFile();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package autoScore;
|
||||
|
||||
public class score {
|
||||
public int getScore (int score,char choose,char anwser){
|
||||
if (choose ==anwser ) {
|
||||
score++;
|
||||
return score;
|
||||
}else {
|
||||
return score;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2020 魏遇卿 All Rights Reserved.
|
||||
* FileName: asdf.java
|
||||
* @author: 魏遇卿@date: 2020/6/11 下午4:50@version: 1.0
|
||||
* E-mail:358614401@qq.com
|
||||
* Code with UTF-8
|
||||
*/
|
||||
|
||||
package autoScore;
|
||||
|
||||
public class useInDemo {
|
||||
public static void main(String[] args) {
|
||||
userIn GUI=new userIn();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (c) 2020 魏遇卿 All Rights Reserved.
|
||||
* FileName: asdf.java
|
||||
* @author: 魏遇卿@date: 2020/6/11 下午4:50@version: 1.0
|
||||
* E-mail:358614401@qq.com
|
||||
* Code with UTF-8
|
||||
*/
|
||||
|
||||
package autoScore;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.CaretEvent;
|
||||
import javax.swing.event.CaretListener;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class userIn extends JFrame implements ActionListener {
|
||||
//设置组件
|
||||
private JButton
|
||||
//创建窗体
|
||||
login = new JButton("login");
|
||||
private JTextField
|
||||
//创建组件
|
||||
admin = new JTextField(),
|
||||
password = new JTextField();
|
||||
private JPanel contentPanel=new JPanel();
|
||||
|
||||
public userIn() {
|
||||
super("Auto score to exam");
|
||||
/* this.setBounds(100,100,100,100);*/
|
||||
//获取主容器并设置为网格组布局
|
||||
// contentPanel = this.getContentPane();
|
||||
contentPanel.setLayout(null);
|
||||
this.setVisible(true);
|
||||
this.setSize(500, 350);//设置窗口大小
|
||||
this.setResizable(false);//设置窗口固定大小
|
||||
this.setLocationRelativeTo(null);//设置窗口居中
|
||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//设置默认关闭操作
|
||||
|
||||
admin.setText("学号");
|
||||
password.setText("password");
|
||||
|
||||
//添加组件
|
||||
contentPanel.setLayout(null);
|
||||
add(admin);
|
||||
add(password);
|
||||
add(login);
|
||||
|
||||
//组件位置
|
||||
admin.setBounds(95,130,300,25);
|
||||
password.setBounds(95,154,300,25);
|
||||
login.setBounds(315,225,90,20);
|
||||
//显示组件
|
||||
admin.setOpaque(false);
|
||||
password.setOpaque(false);
|
||||
login.setOpaque(false);
|
||||
|
||||
//设置监听(鼠标点击之后输入密码
|
||||
admin.addMouseListener(new MouseAdapter(){
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e){
|
||||
int c = e.getButton();
|
||||
if(c == MouseEvent.BUTTON1 && admin.getText().equals("学号") &&e.getClickCount()==1) {
|
||||
admin.setText(null);
|
||||
/* password.setText("password");*/
|
||||
}
|
||||
}
|
||||
});
|
||||
admin.addCaretListener(new CaretListener(){
|
||||
@Override
|
||||
public void caretUpdate(CaretEvent e){
|
||||
|
||||
}
|
||||
});
|
||||
password.addMouseListener(new MouseAdapter(){
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e){
|
||||
int c = e.getButton();
|
||||
if(c == MouseEvent.BUTTON1 && password.getText().equals("password") &&e.getClickCount()==1) {
|
||||
password.setText(null);
|
||||
/* admin.setText("学号");*/
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user