2段階目(抽象クラスとインターフェースを使ってみよう)
This commit is contained in:
18
em-oop/src/Rectangle.java
Normal file
18
em-oop/src/Rectangle.java
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
public class Rectangle extends Shape {
|
||||
|
||||
private double width;
|
||||
private double height;
|
||||
|
||||
public Rectangle(double width, double height) {
|
||||
super("四角形");
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double area() {
|
||||
return width * height;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user