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-08 16:22:55 +01:00
|
|
|
public static final Calendar startCalendar = new GregorianCalendar(2020,Calendar.JANUARY,15,13,0,0);
|
2020-11-09 21:57:28 +01:00
|
|
|
public static final Calendar endCalendar= new GregorianCalendar(2020,Calendar.JANUARY,16,20,0,0);
|
2020-11-08 16:22:55 +01:00
|
|
|
private static final Calendar currentCalendar = (GregorianCalendar)startCalendar.clone();
|
|
|
|
private static boolean ended;
|
2020-10-23 08:29:19 +02:00
|
|
|
|
2020-11-08 16:22:55 +01:00
|
|
|
public static Calendar getStartCalendar() {
|
2020-10-23 08:29:19 +02:00
|
|
|
return startCalendar;
|
|
|
|
}
|
|
|
|
|
2020-11-08 16:22:55 +01:00
|
|
|
public static Calendar getEndCalendar() {
|
2020-10-23 08:29:19 +02:00
|
|
|
return endCalendar;
|
|
|
|
}
|
|
|
|
|
2020-11-08 16:22:55 +01:00
|
|
|
public static Calendar getCurrentCalendar() {
|
2020-10-23 08:29:19 +02:00
|
|
|
return currentCalendar;
|
|
|
|
}
|
|
|
|
|
2020-11-08 16:22:55 +01:00
|
|
|
public static Date getStartTime() {
|
2020-10-23 08:29:19 +02:00
|
|
|
return startCalendar.getTime();
|
|
|
|
}
|
|
|
|
|
2020-11-08 16:22:55 +01:00
|
|
|
public static Date getEndTime(){
|
2020-10-23 08:29:19 +02:00
|
|
|
return endCalendar.getTime();
|
|
|
|
}
|
|
|
|
|
2020-11-08 16:22:55 +01:00
|
|
|
public static Date getCurrentTime() {
|
2020-10-23 08:29:19 +02:00
|
|
|
return currentCalendar.getTime();
|
|
|
|
}
|
|
|
|
|
2020-11-08 16:22:55 +01:00
|
|
|
public static 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-08 16:22:55 +01:00
|
|
|
/**
|
|
|
|
Check if time/date provided falls within the simulation timeline
|
|
|
|
*/
|
|
|
|
public static boolean isValidTime(Date timeToLeaveToDest) {
|
|
|
|
if (timeToLeaveToDest.after(PDate.endCalendar.getTime()) ||
|
|
|
|
timeToLeaveToDest.before(PDate.startCalendar.getTime()))
|
|
|
|
return false;
|
|
|
|
else
|
|
|
|
return true;
|
2020-10-23 08:29:19 +02:00
|
|
|
}
|
|
|
|
|
2020-11-08 16:22:55 +01:00
|
|
|
public static boolean isEnded(){
|
2020-10-23 08:29:19 +02:00
|
|
|
return ended;
|
|
|
|
}
|
|
|
|
|
|
|
|
@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 {
|
|
|
|
|
|
|
|
}
|