Display question.

Realize the function of displaying the problem.
This commit is contained in:
weiyuqing committed 2020-06-16 14:49:43 +08:00
1 parent 2bfc2e441a
commit 38770ae9d6
9 files changed
+90 -24

No files matched your search

Generated
-1
View File
@@ -2,6 +2,5 @@
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" /> <mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/FirstJavaApp" vcs="Git" />
</component> </component>
</project> </project>
Binary file not shown.
Binary file not shown.
Binary file not shown.
+12
View File
@@ -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 {
}
+5 -1
View File
@@ -9,8 +9,12 @@
package autoScore; package autoScore;
import autoScore.userIn; import autoScore.userIn;
import autoScore.*; import autoScore.*;
import java.io.IOException;
public class mainDo{ public class mainDo{
public static void main(String[] args) { public static void main(String[] args) throws IOException {
int score=0;
mainGUI gui=new mainGUI(); mainGUI gui=new mainGUI();
} }
} }
+36 -13
View File
@@ -12,13 +12,21 @@ import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; 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 { public class mainGUI extends JFrame implements ActionListener {
private JTextField question; private JTextArea question;
private JButton A,B,C,D; private JButton A;
private JButton B;
private JButton C;
private JButton D;
int score;
Container c;//创建主容器 Container c;//创建主容器
//构造方法 //构造方法
public mainGUI(){ public mainGUI() throws IOException {
//创建窗口容器 //创建窗口容器
super("Auto score to exam"); super("Auto score to exam");
/* this.setBounds(100,100,100,100);*/ /* 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(); GridBagLayout questtionText = new GridBagLayout();
questionStudent.setBounds(0,0,900,200); 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); this.add(questionStudent);
//pack();
//字体 //字体
questionStudent.setFont(new Font("微软雅黑",Font.BOLD,20)); 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{ /*private class panelABCD extends JPanel implements ActionListener{
}*/ }*/
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
String str = new String();
if(e.getActionCommand().equals("A")){ if(e.getActionCommand().equals("A")){
// return "A"; str= "A";
getScore(score,A,anwer);
} }
if (e.getActionCommand().equals("B")){ if (e.getActionCommand().equals("B")){
// return "B"; str= "B";
} }
if (e.getActionCommand().equals("B")){ if (e.getActionCommand().equals("C")){
// return "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(); mainGUI mainGUI= new mainGUI();
}*/ }*/
}
+36 -8
View File
@@ -15,25 +15,53 @@ public class question {
InputStream in; InputStream in;
InputStreamReader reader=new InputStreamReader(new FileInputStream(fireName)); InputStreamReader reader=new InputStreamReader(new FileInputStream(fireName));
}*/ }*/
public static void readFile() { public static String readFile(int q) throws FileNotFoundException,IOException{
File pathname = question(0); /*File pathname = question(q);
try (FileReader reader = new FileReader(pathname); try (FileReader reader = new FileReader(pathname);
BufferedReader br = new BufferedReader(reader) // 建立一个对象,它把文件内容转成计算机能读懂的语言 BufferedReader br = new BufferedReader(reader) // 建立一个对象,它把文件内容转成计算机能读懂的语言
) { ) {
String line; String line;
//网友推荐更加简洁的写法
while ((line = br.readLine()) != null) { while ((line = br.readLine()) != null) {
// 一次读入一行数据 // 一次读入一行数据
System.out.println(line); System.out.println(line);
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); 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) { br.close();
question(0); String str = sb.toString();
System.out.println(question(0)); return str;
readFile();
} }
//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 -1
View File
@@ -1,7 +1,7 @@
package autoScore; package autoScore;
public class score { 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 ) { if (choose ==anwser ) {
score++; score++;
return score; return score;