创建一个三角形类,成员变量三边,方法求周长,创建类主类A来测试它

package com.hanqi.test;

public class sanjiaoxing {
	 private double a;
	 private double b;
	 private double c;
	public double getA() {
		return a;
	}
	public void setA(double a) {
		this.a = a;
	}
	public double getB() {
		return b;
	}
	public void setB(double b) {
		this.b = b;
	}
	public double getC() {
		return c;
	}
	public void setC(double c) {
		this.c = c;
	}
	
public double getZhouchang()
	{
		return a+b+c;
	}

}

  

package com.hanqi.test;

public class Test07 {

    public static void main(String[] args) {
        sanjiaoxing sjx=new sanjiaoxing();
        sjx.setA(10);
        sjx.setB(20);
        sjx.setC(30);
        System.out.println("三边分别是10,20,30的周长是:"+sjx.getZhouchang());

    }

}

 

posted @ 2016-09-19 20:30  -加勒比海带  阅读(1010)  评论(0编辑  收藏  举报