mirror of
https://github.com/This-weiyuqing/javaAutoScore.git
synced 2026-10-17 18:55:31 +08:00
Display question.
Realize the function of displaying the problem.
This commit is contained in:
1 parent
2bfc2e441a
commit
38770ae9d6
9 files changed
+90
-24
No files matched your search
Generated
-1
@@ -2,6 +2,5 @@
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/FirstJavaApp" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright (c) 2020 魏遇卿 All Rights Reserved.
|
||||
* FileName: answer.java
|
||||
* @author: 魏遇卿@date: 2020/6/16 下午2:46@version: 1.0
|
||||
* E-mail:358614401@qq.com
|
||||
* Code with UTF-8
|
||||
*/
|
||||
|
||||
package autoScore;
|
||||
|
||||
public class answer {
|
||||
}
|
||||
@@ -9,8 +9,12 @@
|
||||
package autoScore;
|
||||
import autoScore.userIn;
|
||||
import autoScore.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class mainDo{
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args) throws IOException {
|
||||
int score=0;
|
||||
mainGUI gui=new mainGUI();
|
||||
}
|
||||
}
|
||||
+36
-13
@@ -12,13 +12,21 @@ import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.IOException;
|
||||
|
||||
import static autoScore.question.readFile;
|
||||
import static autoScore.score.getScore;
|
||||
|
||||
public class mainGUI extends JFrame implements ActionListener {
|
||||
private JTextField question;
|
||||
private JButton A,B,C,D;
|
||||
private JTextArea question;
|
||||
private JButton A;
|
||||
private JButton B;
|
||||
private JButton C;
|
||||
private JButton D;
|
||||
int score;
|
||||
Container c;//创建主容器
|
||||
//构造方法
|
||||
public mainGUI(){
|
||||
public mainGUI() throws IOException {
|
||||
//创建窗口容器
|
||||
super("Auto score to exam");
|
||||
/* this.setBounds(100,100,100,100);*/
|
||||
@@ -34,11 +42,19 @@ public class mainGUI extends JFrame implements ActionListener {
|
||||
//网格组布局管理器
|
||||
|
||||
//创建问题显示位置
|
||||
JLabel questionStudent = new JLabel("这是问题的位置andFuckJavaGUI");
|
||||
JTextArea questionStudent = new JTextArea("这是问题的位置andFuckJavaGUI");
|
||||
GridBagLayout questtionText = new GridBagLayout();
|
||||
questionStudent.setBounds(0,0,900,200);
|
||||
questionStudent.setText("fuckJavaGUI");//更改标签内容
|
||||
questionStudent.setText(readFile(11));//更改标签内容
|
||||
questionStudent.setLineWrap(true);
|
||||
questionStudent.setEditable(false);
|
||||
/* JTextField textAreaOutput = new JTextField();
|
||||
questionStudent.add(new JScrollPane(textAreaOutput));*/
|
||||
questionStudent.cut();
|
||||
questionStudent.copy();
|
||||
this.add(questionStudent);
|
||||
|
||||
//pack();
|
||||
//字体
|
||||
questionStudent.setFont(new Font("微软雅黑",Font.BOLD,20));
|
||||
|
||||
@@ -68,25 +84,32 @@ public class mainGUI extends JFrame implements ActionListener {
|
||||
/*private class panelABCD extends JPanel implements ActionListener{
|
||||
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String str = new String();
|
||||
if(e.getActionCommand().equals("A")){
|
||||
// return "A";
|
||||
str= "A";
|
||||
getScore(score,A,anwer);
|
||||
}
|
||||
if (e.getActionCommand().equals("B")){
|
||||
// return "B";
|
||||
str= "B";
|
||||
|
||||
}
|
||||
if (e.getActionCommand().equals("B")){
|
||||
// return "C";
|
||||
if (e.getActionCommand().equals("C")){
|
||||
str= "C";
|
||||
|
||||
}
|
||||
if (e.getActionCommand().equals("D")){
|
||||
str= "D";
|
||||
|
||||
}
|
||||
if (e.getActionCommand().equals("B")){
|
||||
// return "D";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/*public static void main(String[] args) {
|
||||
/*public clstatic void main(String[] args) throws IOException {
|
||||
mainGUI mainGUI= new mainGUI();
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
@@ -15,25 +15,53 @@ public class question {
|
||||
InputStream in;
|
||||
InputStreamReader reader=new InputStreamReader(new FileInputStream(fireName));
|
||||
}*/
|
||||
public static void readFile() {
|
||||
File pathname = question(0);
|
||||
public static String readFile(int q) throws FileNotFoundException,IOException{
|
||||
/*File pathname = question(q);
|
||||
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();
|
||||
}
|
||||
}*/
|
||||
File filepath=question(q);
|
||||
FileReader rader = new FileReader(filepath);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String s = "";
|
||||
BufferedReader br = new BufferedReader(new FileReader(filepath));
|
||||
|
||||
while ((s = br.readLine()) != null) {
|
||||
sb.append(s );
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
question(0);
|
||||
System.out.println(question(0));
|
||||
readFile();
|
||||
br.close();
|
||||
String str = sb.toString();
|
||||
return str;
|
||||
}
|
||||
//java读取文件返回字符串
|
||||
/* public static String readFile(String filepath) throws FileNotFoundException, IOException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String s = "";
|
||||
BufferedReader br = new BufferedReader(new FileReader(filepath));
|
||||
|
||||
while ((s = br.readLine()) != null) {
|
||||
sb.append(s + "\n");
|
||||
}
|
||||
|
||||
br.close();
|
||||
String str = sb.toString();
|
||||
return str;
|
||||
}*/
|
||||
|
||||
/*public static void main(String[] args) {
|
||||
//question(0);
|
||||
// System.out.println(readFile(4));
|
||||
readFile(0);
|
||||
//System.out.println();
|
||||
|
||||
}*/
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package autoScore;
|
||||
|
||||
public class score {
|
||||
public int getScore (int score,char choose,char anwser){
|
||||
public static int getScore (int score,char choose,char anwser){
|
||||
if (choose ==anwser ) {
|
||||
score++;
|
||||
return score;
|
||||
|
||||
Reference in new issue
Block a user