3日目 段階2 小澤
This commit is contained in:
15
em-oop/src/day3_123/Day3Check2.java
Normal file
15
em-oop/src/day3_123/Day3Check2.java
Normal 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());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
6
em-oop/src/day3_123/Greeting.java
Normal file
6
em-oop/src/day3_123/Greeting.java
Normal file
@@ -0,0 +1,6 @@
|
||||
package day3_123;
|
||||
|
||||
public interface Greeting {
|
||||
String hello();
|
||||
|
||||
}
|
||||
9
em-oop/src/day3_123/JapaneseGreeting.java
Normal file
9
em-oop/src/day3_123/JapaneseGreeting.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package day3_123;
|
||||
|
||||
public class JapaneseGreeting implements Greeting {
|
||||
@Override
|
||||
public String hello() {
|
||||
return "こんにちは";
|
||||
}
|
||||
|
||||
}
|
||||
18
em-oop/src/day3_123/Rectangle.java
Normal file
18
em-oop/src/day3_123/Rectangle.java
Normal 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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user