mirror of
https://github.com/guezoloic/racing-game.git
synced 2026-03-28 18:03:50 +00:00
fix(Rankboard.java): ajout arraylist clone
This commit is contained in:
@@ -243,14 +243,17 @@ public class Game
|
||||
*
|
||||
* @throws InterruptedException si le thread est interrompu pendant wait()
|
||||
*/
|
||||
private synchronized void step() throws InterruptedException
|
||||
private void step() throws InterruptedException
|
||||
{
|
||||
for (int i = 0; i < cars.size(); i++)
|
||||
for (Car car : cars)
|
||||
{
|
||||
while (isPaused)
|
||||
wait();
|
||||
synchronized(this)
|
||||
{
|
||||
while (isPaused)
|
||||
wait();
|
||||
}
|
||||
|
||||
cars.get(i).run();
|
||||
car.run();
|
||||
|
||||
for (GObserver o : obs)
|
||||
{
|
||||
|
||||
@@ -47,10 +47,13 @@ public class Rankboard extends GameView
|
||||
*/
|
||||
private void updateRankText()
|
||||
{
|
||||
cars.sort(Comparator.comparingInt(Car::getScore).reversed());
|
||||
// cloner pour de modifier la classe principale
|
||||
ArrayList<Car> cars_clone = new ArrayList<>(cars);
|
||||
cars_clone.sort(Comparator.comparingInt(Car::getScore).reversed());
|
||||
|
||||
StringBuilder s = new StringBuilder();
|
||||
s.append("<html><table>");
|
||||
for (Car c : cars)
|
||||
for (Car c : cars_clone)
|
||||
{
|
||||
s.append("<tr><td>" + c + ": " + c.getScore() + "%</td></tr>");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user