2020-11-08 21:35:39 +01:00
|
|
|
|
import java.util.ArrayList;
|
2020-10-21 04:42:45 +02:00
|
|
|
|
import java.util.Date;
|
2020-11-06 22:07:50 +01:00
|
|
|
|
|
2020-10-20 01:33:57 +02:00
|
|
|
|
public class Campaign {
|
2020-10-09 21:22:37 +02:00
|
|
|
|
|
2020-11-06 17:21:46 +01:00
|
|
|
|
private String UID;
|
|
|
|
|
//private int housingNumber;
|
2020-11-08 21:35:39 +01:00
|
|
|
|
//private String name; //TODO <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> (:
|
2020-11-06 17:21:46 +01:00
|
|
|
|
private District hotelDistrict;
|
2020-10-09 21:22:37 +02:00
|
|
|
|
|
2020-10-21 04:42:45 +02:00
|
|
|
|
private Route housingToDestRoute;
|
|
|
|
|
private Route destToHousingRoute;
|
|
|
|
|
|
2020-11-08 21:35:39 +01:00
|
|
|
|
private ArrayList<Vehicle> vehicles;
|
2020-10-21 04:42:45 +02:00
|
|
|
|
|
|
|
|
|
//Will be of type PDate after extention
|
|
|
|
|
private Date timeToLeaveToDest;
|
|
|
|
|
private Date timeToLeaveToHousing;
|
|
|
|
|
|
2020-11-06 17:21:46 +01:00
|
|
|
|
private static int numeberOfCampains;
|
|
|
|
|
|
2020-11-06 20:53:08 +01:00
|
|
|
|
public Campaign(District hotelDistrict, int numberofBusses) {
|
2020-11-06 17:21:46 +01:00
|
|
|
|
this.hotelDistrict = hotelDistrict;
|
2020-11-06 20:53:08 +01:00
|
|
|
|
generateBusses(numberofBusses);
|
|
|
|
|
generateUID();
|
2020-10-21 04:42:45 +02:00
|
|
|
|
}
|
2020-10-09 21:22:37 +02:00
|
|
|
|
|
2020-11-08 21:35:39 +01:00
|
|
|
|
public Campaign(District hotelDistrict, ArrayList<Vehicle> vehicles) {
|
2020-11-06 20:53:08 +01:00
|
|
|
|
this.hotelDistrict = hotelDistrict;
|
|
|
|
|
setVehicles(vehicles);
|
|
|
|
|
generateUID();
|
2020-10-21 04:42:45 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Route getHousingToDestRoute() {
|
|
|
|
|
return housingToDestRoute;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setHousingToDestRoute(Route housingToDestRoute) {
|
|
|
|
|
this.housingToDestRoute = housingToDestRoute;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Route getDestToHousingRoute() {
|
|
|
|
|
return destToHousingRoute;
|
|
|
|
|
}
|
2020-10-09 21:22:37 +02:00
|
|
|
|
|
2020-10-21 04:42:45 +02:00
|
|
|
|
public void setDestToHousingRoute(Route destToHousingRoute) {
|
|
|
|
|
this.destToHousingRoute = destToHousingRoute;
|
2020-10-09 21:22:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-06 20:53:08 +01:00
|
|
|
|
public District getHotelDistrict(){ return this.hotelDistrict; }
|
|
|
|
|
|
|
|
|
|
public Date getTimeToLeaveToDest() {
|
|
|
|
|
return timeToLeaveToDest;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-08 16:26:06 +01:00
|
|
|
|
public void setTimeToLeaveToDest(Date timeToLeaveToDest) throws OutOfSimulationTimeException {
|
|
|
|
|
if(PDate.isValidTime(timeToLeaveToDest))
|
|
|
|
|
this.timeToLeaveToDest = timeToLeaveToDest;
|
|
|
|
|
else throw new OutOfSimulationTimeException();
|
2020-11-06 20:53:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Date getTimeToLeaveToHousing() {
|
|
|
|
|
return timeToLeaveToHousing;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-08 16:26:06 +01:00
|
|
|
|
public void setTimeToLeaveToHousing(Date timeToLeaveToHousing) throws OutOfSimulationTimeException {
|
|
|
|
|
if(PDate.isValidTime(timeToLeaveToHousing))
|
|
|
|
|
this.timeToLeaveToHousing = timeToLeaveToHousing;
|
|
|
|
|
else throw new OutOfSimulationTimeException();
|
2020-11-06 20:53:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-10-21 04:42:45 +02:00
|
|
|
|
public int getNumberOfBusses() {
|
|
|
|
|
int busses = 0;
|
|
|
|
|
for (Vehicle vehicle : vehicles){
|
|
|
|
|
if (vehicle instanceof Bus) busses++;
|
|
|
|
|
}
|
|
|
|
|
return busses;
|
2020-10-09 21:22:37 +02:00
|
|
|
|
}
|
2020-11-06 17:21:46 +01:00
|
|
|
|
|
2020-11-08 21:35:39 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ArrayList<Vehicle> getVehicles() {
|
|
|
|
|
return vehicles;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setVehicles(ArrayList<Vehicle> vehicles) {
|
|
|
|
|
if (vehicles != null)
|
|
|
|
|
this.vehicles = vehicles;
|
|
|
|
|
}
|
2020-11-06 20:49:33 +01:00
|
|
|
|
|
2020-11-06 17:21:46 +01:00
|
|
|
|
|
|
|
|
|
public void generateBusses(int number){
|
2020-11-09 09:57:35 +01:00
|
|
|
|
//TODO: discuss. Make new list or add to old list?
|
|
|
|
|
vehicles = new ArrayList<Vehicle>();
|
2020-11-08 21:35:39 +01:00
|
|
|
|
for (int i = 1; i <= number; i++) {
|
2020-11-09 09:57:35 +01:00
|
|
|
|
vehicles.add(new Bus(10));//Throws NullPtrEx
|
2020-11-08 21:35:39 +01:00
|
|
|
|
}
|
2020-11-06 20:53:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void generateUID() {
|
|
|
|
|
numeberOfCampains++;
|
2020-11-08 21:35:39 +01:00
|
|
|
|
this.UID = String.format("CAMP%04d", numeberOfCampains);
|
2020-11-06 21:28:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getUID(){
|
|
|
|
|
return this.UID;
|
2020-11-06 17:21:46 +01:00
|
|
|
|
}
|
2020-10-09 21:22:37 +02:00
|
|
|
|
}
|