Campaign update:

- Remove fields as discussed in first project meeting
	- Add 2 Routes to each object with get/set

Signed-off-by: HeshamTB <hishaminv@gmail.com>
This commit is contained in:
HeshamTB 2020-10-21 05:42:45 +03:00
parent e12c5ec296
commit 49f7be0ceb
2 changed files with 49 additions and 19 deletions

View File

@ -7,5 +7,6 @@ public interface Breakable {
boolean isInAccident();
void collide(Breakable car, Date time);
void _break(Date time);
void fix();
}

View File

@ -1,34 +1,63 @@
import java.util.Date;
public class Campaign {
private int UID;
private int workers;
private int numberOfPeople;
private String district;
private int housingNumber;
private String name;
private boolean local;
private Route housingToDestRoute;
private Route destToHousingRoute;
private Vehicle[] vehicles;
//Will be of type PDate after extention
private Date timeToLeaveToDest;
private Date timeToLeaveToHousing;
public Campaign(int numberOfPeople, String name, Route housingToDestRoute, Route destToHousingRoute) {
setNumberOfPeople(numberOfPeople);
this.name = name;
this.housingToDestRoute = housingToDestRoute;
this.destToHousingRoute = destToHousingRoute;
}
public Campaign(int numberOfPeople){
/*
Make an array of pilgrims based on number of people with
a set ration pilgrims:workers
Assume not local
*/
setNumberOfPeople(numberOfPeople);
}
// public Campaign(Pilgrim[] pilgrims){
// /*
// Calculate number of workers based on number of pilgrims (pilgrims.length;)
// Assume not local
// */
// }
public int getNumberofCars(){
//Assume each car holds 4 workers
return (int)workers/4;
public int getNumberOfPeople() {
return numberOfPeople;
}
public int getNumberOfBusses(){
return 0;//TODO: calc buses?
public void setNumberOfPeople(int numberOfPeople) {
if (numberOfPeople > 0) this.numberOfPeople = numberOfPeople;
else throw new IllegalArgumentException("Negative number of people in camp");
}
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 int getNumberOfBusses() {
int busses = 0;
for (Vehicle vehicle : vehicles){
if (vehicle instanceof Bus) busses++;
}
return busses;
}
}