Compare commits

...

3 Commits

Author SHA1 Message Date
472ea630da depot des derniers livrables 2022-11-21 15:51:47 -05:00
6df297fc82 patch petit bug de modification concurente 2022-11-21 15:51:09 -05:00
773679057e regenerate jar 2022-11-21 15:50:05 -05:00
7 changed files with 8 additions and 1 deletions

BIN
livrables/Class Diagram.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
livrables/pigeons.vpp Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -71,11 +71,14 @@ public class Bird implements Runnable {
public Food findNearestFood() { public Food findNearestFood() {
Food nearestFood = null; Food nearestFood = null;
int minDistance = Integer.MAX_VALUE; int minDistance = Integer.MAX_VALUE;
for (Food f : park.getFoods()) { int i = 0;
while(i < park.getFoods().size()){
Food f = park.getFoods().get(i);
if (this.position.distance(f.getPosition()) < minDistance && f.isFresh()) { if (this.position.distance(f.getPosition()) < minDistance && f.isFresh()) {
nearestFood = f; nearestFood = f;
minDistance = this.position.distance(f.getPosition()); minDistance = this.position.distance(f.getPosition());
} }
i++;
} }
return nearestFood; return nearestFood;
} }

View File

@@ -243,4 +243,8 @@ public class Park extends JPanel implements MouseListener {
} }
} }
public boolean isBusy(){
return (numWriter.get() > 0);
}
} }