Hajj-simulation/src/Route.java
HeshamTB 713e902e05 Route:
- Changed constructor to take
	Enums of District and Mashier
	as endpoint (start, end)

Signed-off-by: HeshamTB <hishaminv@gmail.com>
2020-11-10 00:00:20 +03:00

52 lines
1.2 KiB
Java

public class Route {
private Street[] streets;
private District hotelArea;
private Mashier mashier;
public Route(Street[] streets, District hotelArea, Mashier mashier) {
setStreets(streets);
setHotelArea(hotelArea);
setMashier(mashier);
}
public Street[] getStreets() {
return this.streets;
}
public double getTotalLength() {
double totalLength = 0;
for (Street st : streets){
totalLength += st.getLength();
}
return totalLength;
}
public District getHotelArea() {
return hotelArea;
}
public Mashier getMashier() {
return mashier;
}
private void setStreets(Street[] streets) {
if (streets != null) this.streets = streets;
else throwIllegal();
}
private void setHotelArea(District hotelArea) {
if (hotelArea != null) this.hotelArea = hotelArea;
else throwIllegal();
}
private void setMashier(Mashier mashier) {
if (mashier != null) this.mashier = mashier;
else throwIllegal();
}
private void throwIllegal() {
throw new IllegalArgumentException();
}
}