段階2完了しました

This commit is contained in:
2026-09-16 14:19:34 +09:00
parent 35764bee9e
commit b0f39ec6c9
4 changed files with 22 additions and 5 deletions

View File

@@ -4,6 +4,10 @@ public class Day3Check1 {
public static void main(String[] args) { public static void main(String[] args) {
Circle circle = new Circle(2); Circle circle = new Circle(2);
circle.showInfo(); circle.showInfo();
Rectangle rectangle = new Rectangle(3,4);
rectangle.showInfo();
Greeting greeting = new JapaneseGreeting();
System.out.println(greeting.hello());
} }
} }

4
em-oop/src/Greeting.java Normal file
View File

@@ -0,0 +1,4 @@
public interface Greeting {
String hello();
}

View File

@@ -0,0 +1,9 @@
public class JapaneseGreeting implements Greeting {
@Override
public String hello() {
String str =("こんにちは");
return str;
}
}

View File

@@ -1,13 +1,13 @@
public class Shape { public abstract class Shape {
private String name; private String name;
public Shape (String name) { public Shape (String name) {
this.name = name; this.name = name;
} }
public double area() {
return 0.0; public abstract double area() ;
}
public void showInfo() { public void showInfo() {
System.out.println(this.name + "の面積は" +this.area() + "です"); System.out.println(this.name + "の面積は" +this.area() + "です");
} }