teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

3

ソースの修正

2017/07/19 04:13

投稿

mr-hisa-child
mr-hisa-child

スコア294

answer CHANGED
@@ -20,8 +20,11 @@
20
20
  }
21
21
 
22
22
  public static String getMessage(String a,String b){
23
+ return Stream.of(Judge.values())
23
- Optional<Judge> judge = Stream.of(Judge.values()).filter(j -> j.a.equals(a) && j.b.equals(b)).findAny();
24
+ .filter(j -> j.a.equals(a) && j.b.equals(b))
25
+ .findAny()
24
- return judge.orElse(UNKNOWN).message;
26
+ .orElse(UNKNOWN)
27
+ .message;
25
28
  }
26
29
  ```
27
30
 

2

コメントの指摘対応

2017/07/19 04:13

投稿

mr-hisa-child
mr-hisa-child

スコア294

answer CHANGED
@@ -6,7 +6,8 @@
6
6
  LOW("×","×","低い"),
7
7
  NORMAL("×","○","普通"),
8
8
  SLIGHTLY_HIGH("○","×","やや高い"),
9
- HIGH("○","○","高い");
9
+ HIGH("○","○","高い"),
10
+ UNKNOWN("-","-","");
10
11
 
11
12
  private final String a;
12
13
  private final String b;
@@ -20,8 +21,7 @@
20
21
 
21
22
  public static String getMessage(String a,String b){
22
23
  Optional<Judge> judge = Stream.of(Judge.values()).filter(j -> j.a.equals(a) && j.b.equals(b)).findAny();
23
- return judge.isPresent() ? judge.get().message : "";
24
+ return judge.orElse(UNKNOWN).message;
24
- }
25
25
  }
26
26
  ```
27
27
 

1

ソースの修正

2017/07/19 04:11

投稿

mr-hisa-child
mr-hisa-child

スコア294

answer CHANGED
@@ -20,7 +20,7 @@
20
20
 
21
21
  public static String getMessage(String a,String b){
22
22
  Optional<Judge> judge = Stream.of(Judge.values()).filter(j -> j.a.equals(a) && j.b.equals(b)).findAny();
23
- return judge.get().message;
23
+ return judge.isPresent() ? judge.get().message : "";
24
24
  }
25
25
  }
26
26
  ```