Hajj-simulation/src/Accident.java

45 lines
1.0 KiB
Java
Raw Normal View History

2020-10-16 05:52:46 +02:00
import java.util.Date;
public class Accident {
private Date date;
private Breakable[] involvedCars;
private Street location;
2020-10-16 05:52:46 +02:00
public Accident(Date date, Breakable[] involvedCars, Street location) {
2020-10-16 05:52:46 +02:00
setDate(date);
setInvovledCars(involvedCars);
this.location = location;
2020-10-16 05:52:46 +02:00
}
private void setDate(Date date){
//TODO: maybe change to Calendar type
this.date = date;
2020-10-16 05:52:46 +02:00
}
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 Street getLocation(){
return this.location;
}
2020-10-16 05:52:46 +02:00
public int getTimeToFix(){
int max = 0;
for (Breakable car : involvedCars){
if (car.getTimeToFix() > max) max = car.getTimeToFix();
}
return max;
}
}