回答編集履歴
1
コメントを少し追加!
test
CHANGED
@@ -64,6 +64,8 @@
|
|
64
64
|
|
65
65
|
try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
|
66
66
|
|
67
|
+
//配列から動的配列(ArrayList)に宣言を変更。
|
68
|
+
|
67
69
|
List<ToDo> ToDoList = new ArrayList<>();
|
68
70
|
|
69
71
|
|
@@ -156,7 +158,7 @@
|
|
156
158
|
|
157
159
|
|
158
160
|
|
159
|
-
p
|
161
|
+
private static void display_month_order(List<ToDo> ToDoList) {
|
160
162
|
|
161
163
|
System.out.println("予定です。(月昇順)");
|
162
164
|
|
@@ -166,18 +168,20 @@
|
|
166
168
|
|
167
169
|
public int compare(ToDo todo1, ToDo todo2) {
|
168
170
|
|
171
|
+
// 標準ライブラリのInteger.compareを使用すると、compareをシンプルに記述することができます。
|
172
|
+
|
169
173
|
int month = Integer.compare(todo1.month, todo2.month);
|
170
174
|
|
175
|
+
// ガード節による入れ子条件記述の置き換え
|
176
|
+
|
171
|
-
if (month =
|
177
|
+
if (month != 0) {
|
172
|
-
|
173
|
-
return Integer.compare(todo1.day, todo2.day);
|
174
|
-
|
175
|
-
} else {
|
176
178
|
|
177
179
|
return month;
|
178
180
|
|
179
181
|
}
|
180
182
|
|
183
|
+
return Integer.compare(todo1.day, todo2.day);
|
184
|
+
|
181
185
|
}
|
182
186
|
|
183
187
|
});
|
@@ -188,7 +192,7 @@
|
|
188
192
|
|
189
193
|
|
190
194
|
|
191
|
-
p
|
195
|
+
private static void display_priority_order(List<ToDo> ToDoList) {
|
192
196
|
|
193
197
|
System.out.println("予定です。(優先度昇順)");
|
194
198
|
|
@@ -200,6 +204,4 @@
|
|
200
204
|
|
201
205
|
}
|
202
206
|
|
203
|
-
|
204
|
-
|
205
207
|
```
|