diff --git a/em-oop/src/Circle.java b/em-oop/src/Circle.java new file mode 100644 index 0000000..9000ef7 --- /dev/null +++ b/em-oop/src/Circle.java @@ -0,0 +1,22 @@ + +public class Circle extends Shape { + + private double radius; + + public Circle(double radius) { + super("円"); + this.radius = radius; + + } + + @Override + public double area() { + return Math.PI * radius * radius; + } + + @Override + public void showInfo() { + super.showInfo(); + System.out.println("半径:" + this.radius); + } +} diff --git a/em-oop/src/Day3Check1.java b/em-oop/src/Day3Check1.java new file mode 100644 index 0000000..29a4d34 --- /dev/null +++ b/em-oop/src/Day3Check1.java @@ -0,0 +1,11 @@ + +public class Day3Check1 { + + public static void main(String[] args) { + + Circle circle = new Circle(2.0); + + circle.showInfo(); + } + +} diff --git a/em-oop/src/Shape.java b/em-oop/src/Shape.java new file mode 100644 index 0000000..89829ca --- /dev/null +++ b/em-oop/src/Shape.java @@ -0,0 +1,20 @@ + +public class Shape { + + private String name; + + public Shape(String name) { + this.name = name; + + } + + public double area() { + return 0.0; + + } + + public void showInfo() { + System.out.println(this.name + "の面積は" + this.area() + "です"); + + } +}