2020-10-16 06:27:40 +02:00
|
|
|
package ee364.hajj.transport;
|
|
|
|
|
2020-10-16 05:52:46 +02:00
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
public class Accident {
|
|
|
|
|
|
|
|
private Date date;
|
|
|
|
private Breakable[] involvedCars;
|
|
|
|
//private Street street;
|
|
|
|
|
|
|
|
public Accident(Date date, Breakable[] involvedCars) {
|
|
|
|
setDate(date);
|
|
|
|
setInvovledCars(involvedCars);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void setDate(Date date){
|
|
|
|
Date startOfSimDate = new Date(15000000);
|
|
|
|
//TODO: make a static final class with needed values
|
|
|
|
if (date.before(startOfSimDate)){
|
2020-10-16 06:27:40 +02:00
|
|
|
throw new IllegalArgumentException("Date of ee364.hajj.transport.Accident before t zero");
|
2020-10-16 05:52:46 +02:00
|
|
|
}
|
|
|
|
else this.date = date;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void setInvovledCars(Breakable[] cars){
|
|
|
|
if (cars.length > 1) this.involvedCars = cars;
|
|
|
|
else throw new IllegalArgumentException("Can not make an accident with one car");
|
|
|
|
}
|
|
|
|
|
|
|
|
public Date getDate() {
|
|
|
|
return date;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Breakable[] getInvolvedCars() {
|
|
|
|
return involvedCars;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getTimeToFix(){
|
|
|
|
int max = 0;
|
|
|
|
for (Breakable car : involvedCars){
|
|
|
|
if (car.getTimeToFix() > max) max = car.getTimeToFix();
|
|
|
|
}
|
|
|
|
return max;
|
|
|
|
}
|
|
|
|
}
|