發現的問題:java
改進與擴展(需求分析):
1)規範了代碼樣式;
2)修正了簡繁英切換的問題;
3)修改了界面左下角正確率顯示不正確的問題。
4)加入了乘方和括號的表達式
5)優化了複習錯題集git
語言切換: Simplified_Chinese.setText("簡"); Simplified_Chinese.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { Simplified_ChineseMouseClicked(evt); } }); Traditional_Chinese.setText("/繁"); Traditional_Chinese.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { Traditional_ChineseMouseClicked(evt); } }); English.setText("/English"); English.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { EnglishMouseClicked(evt); } });
建立答題歷史記錄和錯題集: public void Histroy_create() { String path = "f:\\Myapp"; File f = new File(path); if (!f.exists()) { f.mkdirs(); String fileName = "histroy.txt"; File file = new File(f, fileName); if (!file.exists()) { Writer writer = null; try { writer = new OutputStreamWriter(new FileOutputStream(file), "UTF-8"); } catch (UnsupportedEncodingException | FileNotFoundException e) { e.printStackTrace(); } try { if (writer != null) { writer.close(); } } catch (IOException e) { e.printStackTrace(); } } f.mkdirs(); String fileName2 = "histroy_num.txt"; File file2 = new File(f, fileName2); if (!file2.exists()) { Writer writer = null; try { writer = new OutputStreamWriter(new FileOutputStream(file2), "UTF-8"); } catch (UnsupportedEncodingException | FileNotFoundException e) { e.printStackTrace(); } try { if (writer != null) { writer.close(); } } catch (IOException e) { e.printStackTrace(); } } Histroy_saveNum(); } } public void Histroy_save() { FileWriter writer; String fileName = ("f:\\Myapp\\histroy.txt"); try { writer = new FileWriter(fileName, true); writer.write(str); writer.write("\r\n"); writer.close(); } catch (IOException e) { e.printStackTrace(); } } public void Histroy_saveNum() { FileWriter writer2; String fileName2 = ("f:\\Myapp\\histroy_num.txt"); try { writer2 = new FileWriter(fileName2, true); writer2.write(str2); writer2.write("\r\n"); writer2.close(); } catch (IOException e) { e.printStackTrace(); } }
括號: for (int j = 0; j < leftNums; j++) { exp += "("; } if (exp.length() > leftNums && exp.charAt(exp.length() - leftNums - 1) == '^') { int matchPos = i + 1; for (int j = 0; j < leftNums; j++) { exp = exp.substring(0, exp.length() - 1); while (rightPosMap.get(matchPos) <= 0) { matchPos++; } rightPosMap.put(matchPos, rightPosMap.get(matchPos) - 1); } exp += random.nextInt(4); } else { int generateNum = (random.nextInt(40) - 20); if (generateNum < 0 && (leftPosMap.get(i + 1) == 0 || rightPosMap.get(i + 1) == 0)) { exp += "(" + generateNum; rightPosMap.put(i + 1, rightPosMap.get(i + 1) + 1); } else { exp += generateNum; } } int rightNums = rightPosMap.get(i + 1); for (int j = 0; j < rightNums; j++) { exp += ")"; }
去除產生除0: public static ArrayList<ExpAndAns> generateExps(int num) { HashSet<MinPreFormat> hashSet = new HashSet<>(); ArrayList<ExpAndAns> res = new ArrayList<>(); for (int i = 0; i < num; i++) { String exp = generateNewExp(); String postexp = trans(exp); Node root = createExpTree(postexp); MinPreFormat minPreFormat = minPre(root); if (hashSet.contains(minPreFormat)) { i--; } else { Rational ans = calc(postexp); if (ans.getM_down() == 0) { i--; } else { hashSet.add(minPreFormat); res.add(new ExpAndAns(exp, ans)); } } } return res; }
主界面:
編程
答題界面:
app
錯題集:
dom
歷史記錄:
post
覆蓋率:
優化
初次接觸到結對編程,一開始的困難仍是很大的,畢竟是異性,不是在同一個宿舍。只能跑圖書館。結對編程應該是相似於駕駛員和領航員的關係,可是在實踐過程當中確實有些困難,由於基礎不是特別紮實,因此在前面一週基本都在複習JAVA的知識。看源代碼的過程也會有點費解,花的時間比較長。可是總比一我的編程好。在結對過程當中,一旦你有什麼錯誤,對方都能幫你及時指正。總而言之仍是有1+1>2的。