2020-10-23 08:29:19 +02:00
|
|
|
import java.util.Calendar;
|
|
|
|
import java.util.Date;
|
2020-11-08 16:22:55 +01:00
|
|
|
import java.util.GregorianCalendar;
|
2020-10-23 08:29:19 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class to manage and track timeline of Hajj-Simulation
|
|
|
|
*/
|
|
|
|
public class PDate extends Calendar {
|
|
|
|
|
2020-11-11 10:04:50 +01:00
|
|
|
public final Calendar startCalendar;
|
|
|
|
public final Calendar endCalendar;
|
|
|
|
private final Calendar currentCalendar;
|
|
|
|
private boolean ended;
|
2020-10-23 08:29:19 +02:00
|
|
|
|
2020-11-11 10:04:50 +01:00
|
|
|
public PDate(GregorianCalendar start, GregorianCalendar end) {
|
|
|
|
this.startCalendar = start;
|
|
|
|
this.endCalendar = end;
|
|
|
|
this.currentCalendar = (GregorianCalendar)start.clone();
|
|
|
|
}
|
|
|
|
|
|
|
|
public Calendar getStartCalendar() {
|
2020-10-23 08:29:19 +02:00
|
|
|
return startCalendar;
|
|
|
|
}
|
|
|
|
|
2020-11-11 10:04:50 +01:00
|
|
|
public Calendar getEndCalendar() {
|
2020-10-23 08:29:19 +02:00
|
|
|
return endCalendar;
|
|
|
|
}
|
|
|
|
|
2020-11-11 10:04:50 +01:00
|
|
|
public Calendar getCurrentCalendar() {
|
2020-10-23 08:29:19 +02:00
|
|
|
return currentCalendar;
|
|
|
|
}
|
|
|
|
|
2020-11-11 10:04:50 +01:00
|
|
|
public Date getStartTime() {
|
2020-10-23 08:29:19 +02:00
|
|
|
return startCalendar.getTime();
|
|
|
|
}
|
|
|
|
|
2020-11-11 10:04:50 +01:00
|
|
|
public Date getEndTime(){
|
2020-10-23 08:29:19 +02:00
|
|
|
return endCalendar.getTime();
|
|
|
|
}
|
|
|
|
|
2020-11-11 10:04:50 +01:00
|
|
|
public Date getCurrentTime() {
|
2020-10-23 08:29:19 +02:00
|
|
|
return currentCalendar.getTime();
|
|
|
|
}
|
|
|
|
|
2020-11-11 10:04:50 +01:00
|
|
|
public void step(int key, int value){
|
2020-11-09 21:57:28 +01:00
|
|
|
ended = false;
|
|
|
|
Calendar dummy = (GregorianCalendar)currentCalendar.clone();
|
|
|
|
dummy.add(key, value);
|
|
|
|
if (dummy.before(endCalendar)){
|
2020-10-23 08:29:19 +02:00
|
|
|
currentCalendar.add(key, value);
|
|
|
|
}
|
2020-11-09 21:57:28 +01:00
|
|
|
else ended = true;
|
2020-11-08 16:22:55 +01:00
|
|
|
}
|
2020-10-23 08:29:19 +02:00
|
|
|
|
2020-11-11 10:04:50 +01:00
|
|
|
public boolean isEnded(){
|
|
|
|
return ended;
|
|
|
|
}
|
|
|
|
|
2020-11-08 16:22:55 +01:00
|
|
|
/**
|
|
|
|
Check if time/date provided falls within the simulation timeline
|
|
|
|
*/
|
2020-11-11 10:04:50 +01:00
|
|
|
public boolean isWithInTimeline(Date time) {
|
|
|
|
if (time.after(this.endCalendar.getTime()) ||
|
|
|
|
time.before(this.startCalendar.getTime()))
|
2020-11-08 16:22:55 +01:00
|
|
|
return false;
|
|
|
|
else
|
|
|
|
return true;
|
2020-10-23 08:29:19 +02:00
|
|
|
}
|
|
|
|
|
2020-11-11 10:04:50 +01:00
|
|
|
/**
|
|
|
|
Check if time/date provided falls within the simulation timeline
|
|
|
|
with reference to a PDate instance.
|
|
|
|
*/
|
|
|
|
public static boolean isWithInTimeline(Date time, PDate timeManeger) {
|
|
|
|
return time.after(timeManeger.getStartTime()) &&
|
|
|
|
time.before(timeManeger.getEndTime());
|
2020-10-23 08:29:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void computeTime() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void computeFields() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void add(int i, int i1) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void roll(int i, boolean b) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getMinimum(int i) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getMaximum(int i) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getGreatestMinimum(int i) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getLeastMaximum(int i) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2020-11-08 16:22:55 +01:00
|
|
|
|
|
|
|
class OutOfSimulationTimeException extends Exception {
|
|
|
|
|
|
|
|
}
|