回答編集履歴

2

定数化

2020/03/09 09:44

投稿

jimbe
jimbe

スコア12754

test CHANGED
@@ -118,7 +118,7 @@
118
118
 
119
119
 
120
120
 
121
- for(int i=0, left=PLAYERS; !deck.isEmpty() && left>1; i=(i+1)%playerList.size()) {
121
+ for(int i=0, left=PLAYERS; !deck.isEmpty() && left>1; i=(i+1)%PLAYERS) {
122
122
 
123
123
  Player player = playerList.get(i);
124
124
 
@@ -152,7 +152,7 @@
152
152
 
153
153
  for(Player player : playerList) System.out.println(player);
154
154
 
155
- Collections.sort(playerList, (o1,o2)->{ return o2.getHand() - o1.getHand(); });
155
+ Collections.sort(playerList, (o1,o2)->{ return o2.getHand()-o1.getHand(); });
156
156
 
157
157
  Player top = playerList.get(0);
158
158
 

1

勝者無しは無さそうなので削除

2020/03/09 09:44

投稿

jimbe
jimbe

スコア12754

test CHANGED
@@ -156,26 +156,18 @@
156
156
 
157
157
  Player top = playerList.get(0);
158
158
 
159
- if(top.isBankrupt()) {
160
-
161
- System.out.println("No winner");
162
-
163
- } else {
164
-
165
- StringBuilder sb = new StringBuilder(top.getName());
159
+ StringBuilder sb = new StringBuilder(top.getName());
166
-
160
+
167
- for(int i=1; i<playerList.size(); i++) {
161
+ for(int i=1; i<playerList.size(); i++) {
168
-
162
+
169
- if(playerList.get(i).getHand() < top.getHand()) break;
163
+ if(playerList.get(i).getHand() < top.getHand()) break;
170
-
164
+
171
- sb.append(" and "+playerList.get(i).getName());
165
+ sb.append(" and "+playerList.get(i).getName());
172
-
173
- }
174
-
175
- System.out.println("** Winner, "+sb+" !! **");
176
166
 
177
167
  }
178
168
 
169
+ System.out.println("** Winner, "+sb+" !! **");
170
+
179
171
  }
180
172
 
181
173
  }