段階1完了しました。

This commit is contained in:
2026-09-16 13:20:13 +09:00
parent 4b225c0396
commit 35764bee9e
3 changed files with 43 additions and 0 deletions

20
em-oop/src/Circle.java Normal file
View File

@@ -0,0 +1,20 @@
public class Circle extends Shape {
private double radius;
public Circle(double radius) {
super("円");
this.radius = radius;
}
@Override
public double area() {
double num;
num = Math.PI * radius * radius;
return num;
}
@Override
public void showInfo() {
super.showInfo();
System.out.println("(半径:" + this.radius + ")");
}
}

View File

@@ -0,0 +1,9 @@
public class Day3Check1 {
public static void main(String[] args) {
Circle circle = new Circle(2);
circle.showInfo();
}
}

14
em-oop/src/Shape.java Normal file
View File

@@ -0,0 +1,14 @@
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() + "です");
}
}