diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 09a576a..94a25f7 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -2,6 +2,5 @@ - \ No newline at end of file diff --git a/out/production/fuckJavaGui/autoScore/mainDo.class b/out/production/fuckJavaGui/autoScore/mainDo.class index 6d51151..56d9105 100644 Binary files a/out/production/fuckJavaGui/autoScore/mainDo.class and b/out/production/fuckJavaGui/autoScore/mainDo.class differ diff --git a/out/production/fuckJavaGui/autoScore/mainGUI.class b/out/production/fuckJavaGui/autoScore/mainGUI.class index 0fb7a8e..2105e9f 100644 Binary files a/out/production/fuckJavaGui/autoScore/mainGUI.class and b/out/production/fuckJavaGui/autoScore/mainGUI.class differ diff --git a/out/production/fuckJavaGui/autoScore/question.class b/out/production/fuckJavaGui/autoScore/question.class index 667d9d1..a7ec983 100644 Binary files a/out/production/fuckJavaGui/autoScore/question.class and b/out/production/fuckJavaGui/autoScore/question.class differ diff --git a/src/autoScore/answer.java b/src/autoScore/answer.java new file mode 100644 index 0000000..00c64a6 --- /dev/null +++ b/src/autoScore/answer.java @@ -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 { +} diff --git a/src/autoScore/mainDo.java b/src/autoScore/mainDo.java index 20feb1e..f596c74 100644 --- a/src/autoScore/mainDo.java +++ b/src/autoScore/mainDo.java @@ -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(); } } \ No newline at end of file diff --git a/src/autoScore/mainGUI.java b/src/autoScore/mainGUI.java index ae6f961..d7f8b11 100644 --- a/src/autoScore/mainGUI.java +++ b/src/autoScore/mainGUI.java @@ -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(); }*/ -} + diff --git a/src/autoScore/question.java b/src/autoScore/question.java index 941bccf..aa014ef 100644 --- a/src/autoScore/question.java +++ b/src/autoScore/question.java @@ -10,30 +10,58 @@ public class question { 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 questiontext() { + File fireName=question(0); + InputStream in; + InputStreamReader reader=new InputStreamReader(new FileInputStream(fireName)); + }*/ + 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)); - public static void main(String[] args) { - question(0); - System.out.println(question(0)); - readFile(); + while ((s = br.readLine()) != null) { + sb.append(s ); + } + + 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(); + + }*/ } diff --git a/src/autoScore/score.java b/src/autoScore/score.java index 79caf6d..f9346ba 100644 --- a/src/autoScore/score.java +++ b/src/autoScore/score.java @@ -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;