day09-继承抽象案例--图形
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package com.inmind.test08;
|
||||
|
||||
public class Rectangle extends Shape{
|
||||
|
||||
//继承中构造方法的传递值的方式,指定属性值
|
||||
public Rectangle(double chang ,double width){
|
||||
super(chang,width);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public double getArea() {
|
||||
return getChang()*getWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getZC() {
|
||||
return 2*(getChang()+getWidth());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user