Hajj-simulation/src/Campaign.java
2020-11-08 23:35:39 +03:00

108 lines
2.7 KiB
Java

import java.util.ArrayList;
import java.util.Date;
public class Campaign {
private String UID;
//private int housingNumber;
//private String name; //TODO äÈÛÇ ÑÇíß íÇ åÔÇã (:
private District hotelDistrict;
private Route housingToDestRoute;
private Route destToHousingRoute;
private ArrayList<Vehicle> vehicles;
//Will be of type PDate after extention
private Date timeToLeaveToDest;
private Date timeToLeaveToHousing;
private static int numeberOfCampains;
public Campaign(District hotelDistrict, int numberofBusses) {
this.hotelDistrict = hotelDistrict;
generateBusses(numberofBusses);
generateUID();
}
public Campaign(District hotelDistrict, ArrayList<Vehicle> vehicles) {
this.hotelDistrict = hotelDistrict;
setVehicles(vehicles);
generateUID();
}
public Route getHousingToDestRoute() {
return housingToDestRoute;
}
public void setHousingToDestRoute(Route housingToDestRoute) {
this.housingToDestRoute = housingToDestRoute;
}
public Route getDestToHousingRoute() {
return destToHousingRoute;
}
public void setDestToHousingRoute(Route destToHousingRoute) {
this.destToHousingRoute = destToHousingRoute;
}
public District getHotelDistrict(){ return this.hotelDistrict; }
public Date getTimeToLeaveToDest() {
return timeToLeaveToDest;
}
public void setTimeToLeaveToDest(Date timeToLeaveToDest) throws OutOfSimulationTimeException {
if(PDate.isValidTime(timeToLeaveToDest))
this.timeToLeaveToDest = timeToLeaveToDest;
else throw new OutOfSimulationTimeException();
}
public Date getTimeToLeaveToHousing() {
return timeToLeaveToHousing;
}
public void setTimeToLeaveToHousing(Date timeToLeaveToHousing) throws OutOfSimulationTimeException {
if(PDate.isValidTime(timeToLeaveToHousing))
this.timeToLeaveToHousing = timeToLeaveToHousing;
else throw new OutOfSimulationTimeException();
}
public int getNumberOfBusses() {
int busses = 0;
for (Vehicle vehicle : vehicles){
if (vehicle instanceof Bus) busses++;
}
return busses;
}
public ArrayList<Vehicle> getVehicles() {
return vehicles;
}
public void setVehicles(ArrayList<Vehicle> vehicles) {
if (vehicles != null)
this.vehicles = vehicles;
}
public void generateBusses(int number){
for (int i = 1; i <= number; i++) {
vehicles.add(new Bus(10));
}
}
private void generateUID() {
numeberOfCampains++;
this.UID = String.format("CAMP%04d", numeberOfCampains);
}
public String getUID(){
return this.UID;
}
}