回答編集履歴
2
文字列比較はequals
test
CHANGED
@@ -45,3 +45,49 @@
|
|
45
45
|
}
|
46
46
|
|
47
47
|
```
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
---
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
Stringの比較にはequalsを使います。今のままs.equals()を使うとNullPointerExceptionになるので、処理手順を変えます。
|
56
|
+
|
57
|
+
```java
|
58
|
+
|
59
|
+
public static void main(String[] arg) {
|
60
|
+
|
61
|
+
Scanner sc = new Scanner(System.in);
|
62
|
+
|
63
|
+
List<Figure> l = new ArrayList<Figure>();
|
64
|
+
|
65
|
+
String s;
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
while ((s = sc.next()).equals("end")) {
|
70
|
+
|
71
|
+
if (s.equals("c")) {
|
72
|
+
|
73
|
+
double r = sc.nextDouble();
|
74
|
+
|
75
|
+
l.add(new Circle(r));
|
76
|
+
|
77
|
+
} else if (s.equals("r")) {
|
78
|
+
|
79
|
+
double width = sc.nextDouble();
|
80
|
+
|
81
|
+
double height = sc.nextDouble();
|
82
|
+
|
83
|
+
l.add(new Rectangle(width, height));
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
}
|
88
|
+
|
89
|
+
System.out.println(max(l));
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
```
|
1
return間違い
test
CHANGED
@@ -40,7 +40,7 @@
|
|
40
40
|
|
41
41
|
}
|
42
42
|
|
43
|
-
return
|
43
|
+
return ret;
|
44
44
|
|
45
45
|
}
|
46
46
|
|