Compare commits
5 Commits
ba035d4a3c
...
7e13efcb68
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e13efcb68 | ||
|
|
e28c819868 | ||
|
|
48af3a3a99 | ||
|
|
542af2a5d4 | ||
|
|
e6753a16f4 |
@@ -19,4 +19,25 @@ public class Circle extends Shape {
|
|||||||
super.showInfo();
|
super.showInfo();
|
||||||
System.out.println("半径:" + this.radius);
|
System.out.println("半径:" + this.radius);
|
||||||
}
|
}
|
||||||
|
// //Shapeクラスを継承
|
||||||
|
//
|
||||||
|
// //フィールド作成
|
||||||
|
// private double radius;
|
||||||
|
//
|
||||||
|
// //コンストラクタ作成
|
||||||
|
// public Circle(double radius) {
|
||||||
|
// super("円");
|
||||||
|
// this.radius = radius;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //メソッド作成
|
||||||
|
// public double area() {
|
||||||
|
// return Math.PI * radius * radius;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public void showInfo() {
|
||||||
|
// super.showInfo();
|
||||||
|
// System.out.println("(半径:" + this.radius + ")");
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
13
em-oop/src/Day3Check3.java
Normal file
13
em-oop/src/Day3Check3.java
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
public class Day3Check3 {
|
||||||
|
public static void main(String[] ages) {
|
||||||
|
|
||||||
|
Shape shape1 = new Circle(2);
|
||||||
|
shape1.showInfo();
|
||||||
|
|
||||||
|
Shape shape2 = new Rectangle(3, 4);
|
||||||
|
shape2.showInfo();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,20 +1,41 @@
|
|||||||
|
//
|
||||||
|
//public abstract class Shape {
|
||||||
|
//
|
||||||
|
// private String name;
|
||||||
|
//
|
||||||
|
// public Shape(String name) {
|
||||||
|
// this.name = name;
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public abstract double area();
|
||||||
|
// //return 0.0;
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// public void showInfo() {
|
||||||
|
// //System.out.println(this.name + "の面積は" + this.area() + "です");
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
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 abstract double area();
|
//メソッド作成
|
||||||
//return 0.0;
|
double area() {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//メソッド作成
|
||||||
|
void showInfo() {
|
||||||
public void showInfo() {
|
//出力
|
||||||
//System.out.println(this.name + "の面積は" + this.area() + "です");
|
System.out.println(this.name + "の面積は" + this.area() + "です");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user