現在的編寫,進入了一段時間的中堅階段,小夥伴的思路雖然很一致,可是老是存在着必定問題,這就形成了咱們中堅階段的很長一段時間的中止階段;
加油!java
20172316 趙乾宸:負責對於整數出題的編程;
20172319 唐才銘:負責對於分數出題的編程;
我:20172329 王文彬:負責對於計算和題目去重的編寫;
測試爲分別進行測試,最後由趙乾宸進行集體測試。
每一個人都是駕駛員,是彼此的引航員,團隊,分工明確是一部分,可是集體力量的結晶纔是最偉大的!!!
編程
生成題目的相關代碼dom
import java.util.Scanner; public class Compute2 { protected int a; protected String s1 = "", str = ""; public Compute2() { Scanner scan = new Scanner(System.in); System.out.println("幾級運算?"); int n = scan.nextInt(); Scanner qqq = new Scanner(System.in); /* System.out.println("生成幾個題目?"); int q = qqq.nextInt(); Object[] p = new Object[q] ; for (int index = 0; index < q; index++) {*/ int a1 = (int) (Math.random() * 100); int a2 = (int) (Math.random() * 100); int t1 = (int) (Math.random() * 4); switch (t1) { case 0: { s1 = " + "; break; } case 1: { s1 = " - "; break; } case 2: { s1 = " * "; break; } case 3: { s1 = " / "; } } for (int i = 0; i < n - 1; i++) { int a = (int) (Math.random() * 100); int t = (int) (Math.random() * 4); String s = ""; switch (t) { case 0: { s = " + "; break; } case 1: { s = " - "; break; } case 2: { s = " * "; break; } case 3: { s = " / "; } } str += a + s; } str += a1 + s1 + a2; } public String getFormula () { return str; } }
測試:
測試
計算的相關代碼
spa
import java.util.Scanner; public class Compute2 { protected int a; protected String s1 = "", str = ""; public Compute2() { Scanner scan = new Scanner(System.in); System.out.println("幾級運算?"); int n = scan.nextInt(); Scanner qqq = new Scanner(System.in); /* System.out.println("生成幾個題目?"); int q = qqq.nextInt(); Object[] p = new Object[q] ; for (int index = 0; index < q; index++) {*/ int a1 = (int) (Math.random() * 100); int a2 = (int) (Math.random() * 100); int t1 = (int) (Math.random() * 4); switch (t1) { case 0: { s1 = " + "; break; } case 1: { s1 = " - "; break; } case 2: { s1 = " * "; break; } case 3: { s1 = " / "; } } for (int i = 0; i < n - 1; i++) { int a = (int) (Math.random() * 100); int t = (int) (Math.random() * 4); String s = ""; switch (t) { case 0: { s = " + "; break; } case 1: { s = " - "; break; } case 2: { s = " * "; break; } case 3: { s = " / "; } } str += a + s; } str += a1 + s1 + a2; } public String getFormula () { return str; } }
問題1:在作好計算類之後,在測試的時候,發現結果是0?
設計
問題1解決方案:
由於在計算類當中編寫的時候沒有注意對象的運用,使得在一個計算類的方法中重複利用了多個對象,使得彼此相互關聯,以後,在測試類中調用時,就發生了調不出來的情況。3d
原本應該是這個樣子:
code
可是由於方法直接有點問題,一開始一直提示,按照提示將方法都設置成爲了靜態,以後再測試類中再次調用的時候就出現了問題,如今一直在解決於這個問題;orm