结对对象:吴雪琴
对方博客:http://www.cnblogs.com/snowing0119/p/5406105.html
贡献比例:1:1
结对方式:电脑编程,我负责写代码队友主要提供思路并检查错误。
结对图片:

队友优点:想到的问题较为全面,认真且心细,能较清楚的表达出自己的想法和思路。
题目要求:
构造程序,分别是:
1 package wxq.theForth.Second.Cost;
2 import java.util.Scanner;
3 public class Test {
4
5 public static void main(String[] agrs){
6 Scanner input=new Scanner(System.in);
7
8 CostCalculator cost=new CostCalculator(1.0,2.0);//边的花费,内部的花费
9 System.out.println("着色一米的边长需要:"+cost.getBorderCost()+"RMB "+"着色l平方米需要:"+cost.getSoliderCost()+"RMB");
10 double radius=0;
11 double height=0,width=0;
12 double left=0,right=0,boom=0;
13 //*******圆*******
14 System.out.print("请输入圆的半径:");
15 radius=input();
16 Circle circle=new Circle(radius);
17 circle.area();
18 circle.perimeter();
19 circle.paintBorder();//为边着色
20 System.out.println("花费为:"+cost.calculate(circle));
21
22 //*******长方形*******
23 System.out.print("请输入长方形的长:");
24 height=input();
25 System.out.print("请输入长方形的宽:");
26 width=input();
27 Rectangle rectangle=new Rectangle(height,width);
28 rectangle.area();
29 rectangle.perimeter();
30
31 rectangle.paintBorder();//为边着色
32 rectangle.paintShape(); //为内部着色
33 System.out.println("花费为:"+cost.calculate(rectangle));
34
35 //******正方形******
36 System.out.print("请输入正方形的边长:");
37 width=input();
38 Square square=new Square(width);
39 square.area();
40 square.perimeter();
41
42 square.paintBorder(); //为内部着色
43 square.paintShape();
44 System.out.println("花费为:"+cost.calculate(square));
45
46 //******三角形******
47 do{
48 System.out.print("请输入三角形的第一边长:");
49 left=input();
50 System.out.print("请输入三角形的第二边长:");
51 right=input();
52 System.out.print("请输入三角形的第三边长:");
53 boom=input();
54 }while(!judge(left,right,boom));
55 Triangle triangle=new Triangle(left,right,boom);;
56 triangle.area();
57 triangle.perimeter();
58 triangle.paintShape(); //为内部着色
59 System.out.println("花费为:"+cost.calculate(triangle));
60
61 input.close();
62 }
63 public static boolean judgement(double r){
64
65 if(r<0){
66 System.out.println("输入错误,请重新输入");
67 return false;
68 }
69 return true;
70 }
71 public static double input(){
72 double temp=0;
73 boolean flag=true;
74 @SuppressWarnings("resource")
75 Scanner input=new Scanner(System.in);
76 do{
77 flag=true;
78 input=new Scanner(System.in);
79 if(input.hasNextDouble()){
80 temp=input.nextDouble();
81 if(temp>0){
82 flag=false;
83 break;
84 }
85 }
86 System.out.println("输入必须是double型,并且大于0,请重新输入");
87 }while(flag);
88 return temp;
89 }
90 public static boolean judge(double right,double left,double boom){
91 if(right<=0 || left<=0 || boom<=0){
92 System.out.println("输入不满足三角形构造规则,请重新输入");
93 return false;
94 }
95 if(right+left<=boom || right+boom<=left || boom+left<=right){
96 System.out.println("输入不满足三角形构造规则,请重新输入");
97 return false;
98 }
99 if(right-left>=boom || right-boom>=left || boom-left>=right){
100 System.out.println("输入不满足三角形构造规则,请重新输入");
101 return false;
102 }
103 return true;
104 }
105 }
1 package wxq.theForth.Second.Cost;
2
3 public class Triangle extends Shape2D implements SoliderColorable {
4 private double length1;
5 private double length2;
6 private double length3;
7 private boolean flag = false;
8
9 public Triangle(double length1, double length2, double length3) {
10 // TODO Auto-generated constructor stub
11 super();
12 this.length1 = length1;
13 this.length2 = length2;
14 this.length3 = length3;
15 if ((Math.abs(this.length1 - this.length2) < this.length3)
16 && (Math.abs(this.length1 - this.length3) < this.length2)
17 && (Math.abs(this.length3 - this.length2) < this.length1)
18 && (Math.abs(this.length1 + this.length2) > this.length3)
19 && (Math.abs(this.length1 + this.length3) > this.length2)
20 && (Math.abs(this.length3 + this.length2) > this.length1)) {
21 setSuccess(true);
22 System.out.println("构成了一个三条边长分别为:" + this.length1 + ","
23 + this.length2 + "," + this.length3 + "的三角形");
24 } else {
25 setSuccess(false);
26 }
27 }
28
29 public double getLength1() {
30 return length1;
31 }
32
33 public void setLength1(double length1) {
34 this.length1 = length1;
35 }
36
37 public double getLength2() {
38 return length2;
39 }
40
41 public void setLength2(double length2) {
42 this.length2 = length2;
43 }
44
45 public double getLength3() {
46 return length3;
47 }
48
49 public void setLength3(double length3) {
50 this.length3 = length3;
51 }
52
53 public void area() {
54 double p = (getLength1() + getLength2() + getLength3()) / 2;
55 System.out.println("面积为:"
56 + Math.sqrt(p * (p - getLength1()) * (p - getLength2())
57 * (p - getLength3())));
58 this.setArea(Math.sqrt(p * (p - getLength1()) * (p - getLength2())
59 * (p - getLength3())));
60 }
61
62 public void perimeter() {
63 System.out.println("周长为:"
64 + (getLength1() + getLength2() + getLength3()));
65 this.setPerimeter((getLength1() + getLength2() + getLength3()));
66 }
67
68 public void paintShape() {
69 flag = true;
70 System.out.println("三角形正在着色。。。。。");
71 }
72
73 public boolean isShapePainted() {
74 if (flag)
75 return true;
76 else
77 return false;
78 }
79
80 }
1 package wxq.theForth.Second.Cost;
2
3 public class Square extends Rectangle {
4 private double a = 0;
5
6 public Square(double width) {
7 super(width,width);
8 // TODO Auto-generated constructor stub
9 if (width>0) {
10 this.a = width;
11 System.out.println("构成了一个边长为:"+this.a+"的正方形");
12 setSuccess(true);
13 } else {
14 setSuccess(false);
15 }
16 }
17
18 public double getA() {
19 return a;
20 }
21
22 public void setA(double a) {
23 this.a = a;
24 }
25
26 public void area() {
27 this.setArea(getA() * getA());
28 System.out.println("面积为:" + getA() * getA());
29 }
30
31 public void perimeter() {
32 this.setPerimeter(getA() * 4);
33 System.out.println("周长为:" + getA() * 4);
34 }
35
36
37 }
运行截图:

心得体会:跟队友结对编程真心不错,两个人想的总是比一个人想的全面,对于程序的测试有一定的局限性,如何高效的测试,如何科学的测试,如何能得到较高的测试回报率,都是我们该学习的。
原文:http://www.cnblogs.com/wangzuying/p/5406306.html