3日目 段階2 小澤

This commit is contained in:
2026-09-16 15:11:08 +09:00
parent f1ffaf5116
commit 3af0830d41
4 changed files with 48 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
package day3_123;
public class Day3Check2 {
public static void main(String[] args) {
Rectangle rec = new Rectangle(3, 4);
rec.showInfo();
Greeting gre = new JapaneseGreeting();
System.out.println(gre.hello());
}
}

View File

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

View File

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

View File

@@ -0,0 +1,18 @@
package day3_123;
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;
}
}