回答編集履歴
1
追記
test
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
|
13
13
|
```java
|
14
14
|
|
15
|
-
Map<Strin, Object> mp = new HashMap<>();
|
15
|
+
Map<String, Object> mp = new HashMap<>();
|
16
16
|
|
17
17
|
|
18
18
|
|
@@ -67,3 +67,33 @@
|
|
67
67
|
|
68
68
|
|
69
69
|
```
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
普通は、ポリモーフィズムを用いるのでif文は、いりません。
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
```java
|
78
|
+
|
79
|
+
Map<String, Shape> mp = new HashMap<>();
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
中略
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
Shape tmp = mp.get(key);
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
String str = tmp != null ? tmp.toString() : "null";
|
92
|
+
|
93
|
+
double area = tmp != null ? tmp.getArea() : -1;
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
System.out.println(str+" "+area);
|
98
|
+
|
99
|
+
```
|