11月6号
来源:互联网 发布:友声电子称软件下载 编辑:程序博客网 时间:2024/05/01 21:17
//矩形
class Rectangle {
private int width;
private int length;
public Rectangle(int width,int length) {
super();
this.width = width;
this.length = length;
}
public int getPerimeter(){
return this.width *2 + this.length *2;
}
//获得周长
public int getArea(){
return this.width * this.length;
}
//面积
}
//三角形类
class Triangle {
private int height;
private int end;
private int left;
private int right;
public Triangle(int height, int end,int left,int right) {
super();
this.height = height;
this.end = end;
this.left = left;
this.right = right;
}
public int getPerimeter(){
return this.end+this.left+this.right;
}
//获得周长
public int getArea(){
return (this.end * this.height)/2;
}
//面积
}
public class Figure {
public static void main(String[] args) {
Rectangle rec = new Rectangle(12,14);
Triangle tri = new Triangle(8, 10, 9, 11);
System.out.println("矩形的面积是:"+rec.getArea());
System.out.println("矩形的周长是:"+rec.getPerimeter());
System.out.println("三角形的面积是:"+tri.getArea());
System.out.println("三角形的周长是:"+tri.getPerimeter());
}
}
- 11月6号
- 6月11-15号
- 2016年6月11号
- 11月6号练习和心得
- 11月13号
- 11月12号
- 3月11号
- 4月11号
- 11月8号
- 11月13号
- 1月11号
- 11月8号
- 11月25号
- 11月9号
- 11月14号
- 11月20号
- 11月29号
- 11月28号
- vim 插件
- Java获取客户端IP
- FlashBuilder 导入项目报错:无法打开“xxx” xxx 未知 Flex 问题
- H264基本原理
- 现代IM系统中消息推送和存储架构的实现
- 11月6号
- 刘鑫江歌案,请别忘了陈世峰
- The reason why I use CSDN blog
- 一级列表购物车
- 中传思客 javascript获取客户端IP和地址位置信息(资源转载)
- Android如何查看签名文件的值
- 不懂这25个名词,好意思说你懂大数据?
- 2.6 输入一个除空格以外的可见字符(保证在函数scanf中可使用格式说明符%c读入),输出其ASCII码。
- 马云害怕的事还是发生了