Add isDone() boolean method to Accident
isDone() checks all invovlved CivilVehicles in Accident instance. If any car has reference to 'this' then it is still not done. Done would be true if fix() of each car is invoked. Signed-off-by: HeshamTB <hishaminv@gmail.com>
This commit is contained in:
parent
eabe86923d
commit
e65d3d16e9
@ -41,4 +41,19 @@ public class Accident {
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
public boolean isDone(){
|
||||
for (Breakable car : this.involvedCars){
|
||||
/*
|
||||
if broken flag is set and currAcc is ref to this instance
|
||||
then the accident is not done.
|
||||
The ref to accident should be null if fix() of car is invoked
|
||||
*/
|
||||
if (car.isBroken() &&
|
||||
((CivilVehicle)car).getCurrentAccident() == this) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user