黄国柱-201306114432 http://www.cnblogs.com/zzhuzi/
范铭祥-201306114431 http://www.cnblogs.com/vip-fan1234xiang/
这次做的是TDD;看了半个多小时的视频才动手。
在原来的程序上加了TDD工具;把一个类做成TDD;只要用到他就可以生成运算符;
class yy { private int max=4; private int min=1; private double w2,m2; private String ff; Random random = new Random(); //System.out.println(s); public yy() { int s = random.nextInt(max)%(max-min+1) + min; double x=random.nextInt(max-2)%(max-2-min+1) + min; double y=random.nextInt(max-1)%(max-1-min+1) + min; int y1up=(int) Math.pow(10,x); int y1dn=(int) Math.pow(10,x-1); int y2up=(int) Math.pow(10,y); int y2dn=(int) Math.pow(10,y-1); int x_y1=random.nextInt(y1up)%(y1up-y1dn+1) + y1dn; int x_y2=random.nextInt(y2up)%(y2up-y2dn+1) + y2dn; double w=(double)x_y1; double m=(double)x_y2; this.w2=w; this.m2=m; switch(s) { case 1: { this.ff="+"; System.out.println(w+"+"+m+"=" ); break; } case 2: { this.ff="-"; System.out.println(w+"-"+m+"=" ); break; } case 3: { this.ff="*"; System.out.println(w+"*"+m+"=" ); break; } case 4: { this.ff="/"; System.out.println(w+"/"+m+"=" ); break; } } } public double ret1() { return w2; } public double ret2() { return m2; } public String ret3() { return ff; } }
总结:只有自己动手才会学到东西;
时间: 2024-12-20 03:04:36