total pain
This commit is contained in:
parent
bcebce2a6a
commit
a3f6e8c4dc
10 changed files with 294 additions and 168 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -12,14 +12,37 @@ public class App {
|
||||||
public static final Lesson[][][] timeTable = new Lesson[ROOM_COUNT][DAY_COUNT][LESSON_COUNT];
|
public static final Lesson[][][] timeTable = new Lesson[ROOM_COUNT][DAY_COUNT][LESSON_COUNT];
|
||||||
private static final Teacher[] teachers = new Teacher[Teacher.nameMap.size()];
|
private static final Teacher[] teachers = new Teacher[Teacher.nameMap.size()];
|
||||||
|
|
||||||
// URLs for fetching CO2 data
|
// Date constants
|
||||||
private static final String ROOM_39_URL = "https://api.thingspeak.com/channels/1521262/feeds.csv?results=8000";
|
private static final int START_YEAR = 2024;
|
||||||
private static final String ROOM_38_URL = "https://api.thingspeak.com/channels/1364580/feeds.csv?results=8000";
|
private static final int START_MONTH = 11; // November
|
||||||
private static final String ROOM_37_URL = "https://api.thingspeak.com/channels/1521263/feeds.csv?results=8000";
|
private static final int START_DAY = 4;
|
||||||
|
private static final String START_DATE = String.format("%d-%02d-%02d%%2000:00:00", START_YEAR, START_MONTH,
|
||||||
|
START_DAY);
|
||||||
|
|
||||||
private static final List<Co2Data> room39Data = Co2Data.getData(ROOM_39_URL, 39);
|
private static final int END_YEAR = 2024;
|
||||||
private static final List<Co2Data> room38Data = Co2Data.getData(ROOM_38_URL, 38);
|
private static final int END_MONTH = 11; // November
|
||||||
private static final List<Co2Data> room37Data = Co2Data.getData(ROOM_37_URL, 37);
|
private static final int END_DAY = 8;
|
||||||
|
private static final String END_DATE = String.format("%d-%02d-%02d%%2000:00:00", END_YEAR, END_MONTH, END_DAY);
|
||||||
|
|
||||||
|
// Room channel numbers
|
||||||
|
private static final int ROOM_39_NUMBER = 1521262;
|
||||||
|
private static final int ROOM_38_NUMBER = 1364580;
|
||||||
|
private static final int ROOM_37_NUMBER = 1521263;
|
||||||
|
|
||||||
|
// Room URLs
|
||||||
|
private static final String ROOM_39_URL = createUrl(ROOM_39_NUMBER);
|
||||||
|
private static final String ROOM_38_URL = createUrl(ROOM_38_NUMBER);
|
||||||
|
private static final String ROOM_37_URL = createUrl(ROOM_37_NUMBER);
|
||||||
|
|
||||||
|
// Room data
|
||||||
|
private static final List<Co2Data> ROOM_39_DATA = Co2Data.getData(ROOM_39_URL, 39);
|
||||||
|
private static final List<Co2Data> ROOM_38_DATA = Co2Data.getData(ROOM_38_URL, 38);
|
||||||
|
private static final List<Co2Data> ROOM_37_DATA = Co2Data.getData(ROOM_37_URL, 37);
|
||||||
|
|
||||||
|
private static String createUrl(int channelNumber) {
|
||||||
|
return String.format("https://api.thingspeak.com/channels/%d/feeds.csv?start=%s&end=%s", channelNumber,
|
||||||
|
START_DATE, END_DATE);
|
||||||
|
}
|
||||||
|
|
||||||
// #region Initialization
|
// #region Initialization
|
||||||
private static void initializeTeachers() {
|
private static void initializeTeachers() {
|
||||||
|
@ -36,21 +59,21 @@ public class App {
|
||||||
}
|
}
|
||||||
|
|
||||||
// #region Calculation
|
// #region Calculation
|
||||||
private static void calculatePoints(List<Co2Data> data) {
|
private static void calculatePoints(List<Co2Data> data, int roomNumber) {
|
||||||
for (Co2Data co2Data : data) {
|
for (Co2Data co2Data : data) {
|
||||||
Date temp = co2Data.getDate();
|
Date temp = co2Data.getDate();
|
||||||
int intHour = temp.getHour();
|
int intHour = temp.getHour();
|
||||||
int intMinute = temp.getMinute();
|
int intMinute = temp.getMinute();
|
||||||
int intDay = temp.getDay();
|
|
||||||
if (FillTable.isBreak(intHour, intMinute)) {
|
if (FillTable.isBreak(intHour, intMinute)) {
|
||||||
String whatBreak = FillTable.whatBreakIsIt(intHour, intMinute, intDay);
|
String whatBreak = FillTable.whatBreakIsIt(intHour, intMinute);
|
||||||
|
int[] time = FillTable.whatTime(intHour, intMinute);
|
||||||
|
|
||||||
switch (whatBreak) {
|
switch (whatBreak) {
|
||||||
case "short":
|
case "short":
|
||||||
calculateFiveMinuteBreakPoints(co2Data);
|
calculateFiveMinuteBreakPoints(data, time, roomNumber);
|
||||||
break;
|
break;
|
||||||
case "long":
|
case "long":
|
||||||
calculateLongerBreakPoints(co2Data);
|
calculateLongerBreakPoints(data, time, roomNumber);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -60,18 +83,106 @@ public class App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int calculateFiveMinuteBreakPoints(Co2Data data) {
|
private static int calculateFiveMinuteBreakPoints(List<Co2Data> data, int[] time, int roomNumber) {
|
||||||
calculateBonusPoints(data);
|
// Calculate the time range for the break (e.g., a 5-minute break)
|
||||||
return 5;
|
int startMinute = time[0];
|
||||||
|
int endMinute = time[1];
|
||||||
|
|
||||||
|
int points = 5; // Start with maximum points
|
||||||
|
|
||||||
|
// Loop over each minute in the break and check the CO2 level
|
||||||
|
for (int i = startMinute; i < endMinute; i++) {
|
||||||
|
// Get the CO2 data for the current minute (using the data list)
|
||||||
|
Co2Data minuteData = getCo2DataForMinute(data, i); // data is already a List<Co2Data>
|
||||||
|
|
||||||
|
if (minuteData != null) {
|
||||||
|
int currentCo2 = minuteData.getCo2Level();
|
||||||
|
Co2Data previousMinuteData = getCo2DataForMinute(data, i - 1); // data is a List<Co2Data>
|
||||||
|
|
||||||
|
if (previousMinuteData != null) {
|
||||||
|
int previousCo2 = previousMinuteData.getCo2Level();
|
||||||
|
|
||||||
|
// If CO2 level doesn't decrease, subtract points
|
||||||
|
if (currentCo2 >= previousCo2) {
|
||||||
|
points--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// After calculating the points, consider any bonus points for teacher switch or
|
||||||
|
// other criteria
|
||||||
|
points += calculateBonusPoints(data, time, roomNumber);
|
||||||
|
|
||||||
|
return Math.max(points, 0); // Ensure that points don't go below zero
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int calculateLongerBreakPoints(Co2Data data) {
|
private static int calculateLongerBreakPoints(List<Co2Data> data, int[] time, int roomNumber) {
|
||||||
calculateBonusPoints(data);
|
// Take the time for the entire break
|
||||||
return 10;
|
int startMinute = time[0];
|
||||||
|
int endMinute = time[1];
|
||||||
|
|
||||||
|
int points = 10; // Start with maximum points for longer break
|
||||||
|
|
||||||
|
// Loop over each minute in the break and check the CO2 level
|
||||||
|
for (int i = startMinute; i < endMinute; i++) {
|
||||||
|
// Get the CO2 data for the current minute (using the data list)
|
||||||
|
Co2Data minuteData = getCo2DataForMinute(data, i); // data is already a List<Co2Data>
|
||||||
|
|
||||||
|
if (minuteData != null) {
|
||||||
|
int currentCo2 = minuteData.getCo2Level();
|
||||||
|
Co2Data previousMinuteData = getCo2DataForMinute(data, i - 1); // data is a List<Co2Data>
|
||||||
|
|
||||||
|
if (previousMinuteData != null) {
|
||||||
|
int previousCo2 = previousMinuteData.getCo2Level();
|
||||||
|
|
||||||
|
// If CO2 level doesn't decrease, subtract points
|
||||||
|
if (currentCo2 >= previousCo2) {
|
||||||
|
points--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// After calculating the points, consider any bonus points for teacher switch or
|
||||||
|
// other criteria
|
||||||
|
points += calculateBonusPoints(data, time, roomNumber);
|
||||||
|
|
||||||
|
return Math.max(points, 0); // Ensure that points don't go below zero
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int calculateBonusPoints(Co2Data data) {
|
private static int calculateBonusPoints(List<Co2Data> data, int[] time, int roomNumber) {
|
||||||
return 5;
|
// Check if the next lesson isn't lunch or the same teacher (if the next lesson
|
||||||
|
// is lunch, no bonus points possible)
|
||||||
|
boolean isTeacherChange = isTeacherChange(data, roomNumber); // Check if the teacher is changing
|
||||||
|
boolean isNextLessonLunch = isNextLessonLunch(data, roomNumber);
|
||||||
|
|
||||||
|
if (!isNextLessonLunch && isTeacherChange) {
|
||||||
|
return 5; // Bonus points for teacher switch
|
||||||
|
} else {
|
||||||
|
return 0; // No bonus points
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isTeacherChange(List<Co2Data> data, int roomNumber) {
|
||||||
|
|
||||||
|
return false; // Placeholder logic
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isNextLessonLunch(List<Co2Data> data, int roomNumber) {
|
||||||
|
// Logic to check if the next lesson is lunch (can be based on time and lesson
|
||||||
|
// schedule)
|
||||||
|
return false; // Placeholder logic
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Co2Data getCo2DataForMinute(List<Co2Data> data, int minute) {
|
||||||
|
// Logic to get the CO2 data for a specific minute in the break
|
||||||
|
for (Co2Data co2Data : data) {
|
||||||
|
if (co2Data.getDate().getMinute() == minute) {
|
||||||
|
return co2Data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null; // Return null if no data matches
|
||||||
}
|
}
|
||||||
|
|
||||||
// #region Sorting Printing
|
// #region Sorting Printing
|
||||||
|
@ -109,10 +220,8 @@ public class App {
|
||||||
while (true) {
|
while (true) {
|
||||||
if (scanner.hasNextInt()) {
|
if (scanner.hasNextInt()) {
|
||||||
return scanner.nextInt();
|
return scanner.nextInt();
|
||||||
} else {
|
|
||||||
System.out.println("Invalid input. Please enter a number.");
|
|
||||||
scanner.next();
|
|
||||||
}
|
}
|
||||||
|
scanner.next(); // Clear invalid input
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +229,8 @@ public class App {
|
||||||
System.out.println("Point calculation explanation:");
|
System.out.println("Point calculation explanation:");
|
||||||
System.out.println("1. Up to 5 points for keeping the window open during a small pause.");
|
System.out.println("1. Up to 5 points for keeping the window open during a small pause.");
|
||||||
System.out.println("2. Up to 10 points for long pauses, depending on window usage.");
|
System.out.println("2. Up to 10 points for long pauses, depending on window usage.");
|
||||||
System.out.println("3. 5 bonus points for teacher switches in the room.");
|
System.out.println("3. 5 bonus points for teacher switches in classrooms.");
|
||||||
|
System.out.println("4. Deduct points if CO2 levels are too high.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void printShutDown() {
|
private static void printShutDown() {
|
||||||
|
@ -130,17 +240,16 @@ public class App {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Thread.currentThread().interrupt();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println("Goodbye!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @TODO: remove this before hand-in deadline
|
// @TODO: remove this before hand-in deadline
|
||||||
public static void debbugingValueLists(List<Co2Data> data) {
|
public static void debbugingValueLists(List<Co2Data> data) {
|
||||||
// Debugging co2Data
|
// Debugging co2Data
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (Co2Data a : room37Data) {
|
for (Co2Data a : data) {
|
||||||
System.out.println(a.toString());
|
System.out.println(a.toString());
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
@ -153,16 +262,16 @@ public class App {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
boolean debbugingList = false;
|
boolean debbugingList = false;
|
||||||
if (debbugingList) {
|
if (debbugingList) {
|
||||||
debbugingValueLists(room37Data);
|
debbugingValueLists(ROOM_37_DATA);
|
||||||
// debbugingValueLists(room38Data);
|
// debbugingValueLists(room38Data);
|
||||||
// debbugingValueLists(room39Data);
|
// debbugingValueLists(room39Data);
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Calculations in process please do not shut off...");
|
System.out.println("Calculations in process please do not shut off...");
|
||||||
fillInTimeTable();
|
fillInTimeTable();
|
||||||
initializeTeachers();
|
initializeTeachers();
|
||||||
calculatePoints(room37Data);
|
calculatePoints(ROOM_37_DATA, 37);
|
||||||
calculatePoints(room38Data);
|
calculatePoints(ROOM_38_DATA, 38);
|
||||||
calculatePoints(room39Data);
|
calculatePoints(ROOM_39_DATA, 39);
|
||||||
sortTeachers();
|
sortTeachers();
|
||||||
printTeachers();
|
printTeachers();
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.GregorianCalendar;
|
|
||||||
|
|
||||||
public class Date {
|
public class Date {
|
||||||
// #region Fields
|
// #region Fields
|
||||||
private int day;
|
private int day;
|
||||||
|
@ -42,34 +39,9 @@ public class Date {
|
||||||
return minute;
|
return minute;
|
||||||
}
|
}
|
||||||
|
|
||||||
// #region Helper Method to Check Daylight Saving Time
|
|
||||||
private boolean isDaylightSavingTime() {
|
|
||||||
Calendar calendar = new GregorianCalendar();
|
|
||||||
calendar.set(year, month - 1, day); // Month is 0-based in Calendar
|
|
||||||
|
|
||||||
// Last Sunday in March (DST starts)
|
|
||||||
Calendar lastSundayInMarch = new GregorianCalendar(year, Calendar.MARCH, 31);
|
|
||||||
lastSundayInMarch.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
|
|
||||||
lastSundayInMarch.add(Calendar.DATE, -7); // Go back to last Sunday of March
|
|
||||||
|
|
||||||
// Last Sunday in October (DST ends)
|
|
||||||
Calendar lastSundayInOctober = new GregorianCalendar(year, Calendar.OCTOBER, 31);
|
|
||||||
lastSundayInOctober.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
|
|
||||||
lastSundayInOctober.add(Calendar.DATE, -7); // Go back to last Sunday of October
|
|
||||||
|
|
||||||
// Check if the current date is within the DST period
|
|
||||||
return calendar.after(lastSundayInMarch) && calendar.before(lastSundayInOctober);
|
|
||||||
}
|
|
||||||
|
|
||||||
// #region Adjust UTC to Switzerland Time
|
// #region Adjust UTC to Switzerland Time
|
||||||
private void adjustForSwitzerlandTime() {
|
private void adjustForSwitzerlandTime() {
|
||||||
if (isDaylightSavingTime()) {
|
hour += 1;
|
||||||
// Switzerland is UTC +2 during DST (CEST)
|
|
||||||
hour += 2;
|
|
||||||
} else {
|
|
||||||
// Switzerland is UTC +1 during Standard Time (CET)
|
|
||||||
hour += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Adjust if the hour exceeds 24 or falls below 0
|
// Adjust if the hour exceeds 24 or falls below 0
|
||||||
if (hour >= 24) {
|
if (hour >= 24) {
|
||||||
|
|
|
@ -1,120 +1,165 @@
|
||||||
public class FillTable {
|
public class FillTable {
|
||||||
// #region Constants
|
// #region Constants
|
||||||
private static final String[] START_TIMES = {
|
private static final String[] START_TIMES = {
|
||||||
"7:45", "8:35", "9:40", "10:30", "11:20", "12:10", "12:50",
|
"7:45", "8:35", "9:40", "10:30", "11:20", "12:10", "12:50",
|
||||||
"13:35", "14:25", "15:15", "16:15", "17:05"
|
"13:35", "14:25", "15:15", "16:15", "17:05"
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final String[] END_TIMES = {
|
private static final String[] END_TIMES = {
|
||||||
"8:30", "9:20", "10:25", "11:15", "12:05", "12:50", "13:30",
|
"8:30", "9:20", "10:25", "11:15", "12:05", "12:50", "13:30",
|
||||||
"14:20", "15:10", "16:10", "17:00", "17:50"
|
"14:20", "15:10", "16:10", "17:00", "17:50"
|
||||||
};
|
};
|
||||||
|
|
||||||
// #region Helper Methods
|
// #region Helper Methods
|
||||||
private static void fillTable(String[] teacherShortNames, String day, String[] startTime, String[] endTime,
|
private static void fillTable(String[] teacherShortNames, String day, String[] startTime, String[] endTime,
|
||||||
int roomIndex) {
|
int roomIndex) {
|
||||||
int dayIndex = getDayIndex(day);
|
int dayIndex = getDayIndex(day);
|
||||||
for (int i = 0; i < teacherShortNames.length && i < startTime.length && i < endTime.length; i++) {
|
for (int i = 0; i < teacherShortNames.length && i < startTime.length && i < endTime.length; i++) {
|
||||||
Teacher teacher = new Teacher(teacherShortNames[i]); // Initialize Teacher with shortform
|
Teacher teacher = new Teacher(teacherShortNames[i]); // Initialize Teacher with shortform
|
||||||
App.timeTable[roomIndex][dayIndex][i] = new Lesson(roomIndex, teacher.getName(), startTime[i],
|
App.timeTable[roomIndex][dayIndex][i] = new Lesson(roomIndex, teacher.getName(), startTime[i],
|
||||||
endTime[i],
|
endTime[i],
|
||||||
day);
|
day);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getDayIndex(String day) {
|
||||||
|
switch (day) {
|
||||||
|
case "Monday":
|
||||||
|
return 0;
|
||||||
|
case "Tuesday":
|
||||||
|
return 1;
|
||||||
|
case "Wednesday":
|
||||||
|
return 2;
|
||||||
|
case "Thursday":
|
||||||
|
return 3;
|
||||||
|
case "Friday":
|
||||||
|
return 4;
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// #region Fill 37
|
||||||
|
static void fill37TimeTable() {
|
||||||
|
int roomIndex = 0;
|
||||||
|
fillTable(new String[] { "Hm", "Hm", "Hi", "Hm", "Hm", "Lunch", "Bd", "Gi", "Gi", "Ts", "Ts", "" },
|
||||||
|
"Monday", START_TIMES, END_TIMES, roomIndex);
|
||||||
|
fillTable(new String[] { "Ts", "Ts", "Ts", "Ts", "Le", "Lunch", "Lunch", "Fh", "Fh", "Fh", "Fh", "" },
|
||||||
|
"Tuesday", START_TIMES, END_TIMES, roomIndex);
|
||||||
|
fillTable(new String[] { "Lu", "Lu", "Lu", "Lu", "Cg", "Cg", "Lunch", "Se", "Se", "Se", "Se", "" },
|
||||||
|
"Wednesday", START_TIMES, END_TIMES, roomIndex);
|
||||||
|
fillTable(new String[] { "Gi", "Gi", "Ba", "Ba", "Ba", "Lunch", "Bd", "Du", "Lz", "Lz" },
|
||||||
|
"Thursday", START_TIMES, END_TIMES, roomIndex);
|
||||||
|
fillTable(new String[] { "Kp", "KP", "Or", "Vt", "Vt", "Lunch", "Lunch", "Du", "Du", "Du", "", "" },
|
||||||
|
"Friday", START_TIMES, END_TIMES, roomIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// #region Fill 38
|
||||||
|
static void fill38TimeTable() {
|
||||||
|
int roomIndex = 1;
|
||||||
|
fillTable(new String[] { "Bz", "Bz", "Bz", "Bz", "Bz", "Lunch", "Lunch", "Hn", "Hn", "Bu", "Hn", "Hn" },
|
||||||
|
"Monday", START_TIMES, END_TIMES, roomIndex);
|
||||||
|
fillTable(new String[] { "Kg", "Kg", "Eh", "Re", "Re", "Lunch", "Lunch", "Bt", "Kh", "Kh", "", "" },
|
||||||
|
"Tuesday", START_TIMES, END_TIMES, roomIndex);
|
||||||
|
fillTable(new String[] { "Cg", "Cg", "Cg", "Cg", "Es", "Lunch", "Lunch", "Cg", "Cg", "", "", "" },
|
||||||
|
"Wednesday", START_TIMES, END_TIMES, roomIndex);
|
||||||
|
fillTable(new String[] { "Do", "Do", "Gr", "Gr", "Or", "Lunch", "Lunch", "Bu", "Bu", "Zu", "", "" },
|
||||||
|
"Thursday", START_TIMES, END_TIMES, roomIndex);
|
||||||
|
fillTable(new String[] { "", "Hu", "Ge", "Eh", "Eh", "Bu", "Lunch", "Eh", "Eh", "", "", "" },
|
||||||
|
"Friday", START_TIMES, END_TIMES, roomIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// #region Fill 39
|
||||||
|
static void fill39TimeTable() {
|
||||||
|
int roomIndex = 2;
|
||||||
|
fillTable(new String[] { "Bd", "Bd", "Bd", "Bd", "Bd", "Lunch", "Lunch", "Lu", "Lu", "Lu", "Lu", "" },
|
||||||
|
"Monday", START_TIMES, END_TIMES, roomIndex);
|
||||||
|
fillTable(new String[] { "Do", "Do", "Zu", "Zu", "Zu", "Lunch", "Lunch", "Se", "Se", "Se", "Se", "" },
|
||||||
|
"Tuesday", START_TIMES, END_TIMES, roomIndex);
|
||||||
|
fillTable(new String[] { "Cg", "Cg", "Cg", "Cg", "Bu", "Lunch", "Lunch", "Gi", "Gi", "Gi", "Gi", "" },
|
||||||
|
"Wednesday", START_TIMES, END_TIMES, roomIndex);
|
||||||
|
fillTable(new String[] { "Bd", "Bd", "Bd", "Bd", "Or", "Lunch", "Lunch", "Le", "Le", "Le", "", "" },
|
||||||
|
"Thursday", START_TIMES, END_TIMES, roomIndex);
|
||||||
|
fillTable(new String[] { "Gi", "Gi", "Gr", "Gr", "Gi", "Lunch", "Lunch", "Hi", "Hi", "Hi", "", "" },
|
||||||
|
"Friday", START_TIMES, END_TIMES, roomIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean isBreak(int intHour, int intMinute) {
|
||||||
|
// Check if the time is between 7 AM and 5 PM
|
||||||
|
if (intHour >= 7 && intHour <= 17) {
|
||||||
|
// Check if the time falls between any lesson start and end times
|
||||||
|
for (int i = 0; i < START_TIMES.length; i++) {
|
||||||
|
// Split the start and end times into hours and minutes
|
||||||
|
String[] startTime = START_TIMES[i].split(":");
|
||||||
|
String[] endTime = END_TIMES[i].split(":");
|
||||||
|
|
||||||
|
int startHour = Integer.parseInt(startTime[0]);
|
||||||
|
int startMinute = Integer.parseInt(startTime[1]);
|
||||||
|
int endHour = Integer.parseInt(endTime[0]);
|
||||||
|
int endMinute = Integer.parseInt(endTime[1]);
|
||||||
|
|
||||||
|
// Check if the given time is during the current lesson
|
||||||
|
if ((intHour > startHour || (intHour == startHour && intMinute >= startMinute)) &&
|
||||||
|
(intHour < endHour || (intHour == endHour && intMinute < endMinute))) {
|
||||||
|
return false; // It's not a break, it's during a lesson
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return true; // If no lessons match, it must be a break
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getDayIndex(String day) {
|
return false; // Time is outside of the school hours (7 AM to 6 PM roughly)
|
||||||
switch (day) {
|
}
|
||||||
case "Monday":
|
|
||||||
return 0;
|
|
||||||
case "Tuesday":
|
|
||||||
return 1;
|
|
||||||
case "Wednesday":
|
|
||||||
return 2;
|
|
||||||
case "Thursday":
|
|
||||||
return 3;
|
|
||||||
case "Friday":
|
|
||||||
return 4;
|
|
||||||
default:
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// #region Fill 37
|
static String whatBreakIsIt(int intHour, int intMinute) {
|
||||||
static void fill37TimeTable() {
|
String whatBreak = "";
|
||||||
int roomIndex = 0;
|
for (int i = 0; i < END_TIMES.length; i++) {
|
||||||
fillTable(new String[] { "Hm", "Hm", "Hi", "Hm", "Hm", "Lunch", "Bd", "Gi", "Gi", "Ts", "Ts", "" },
|
String[] tempEnd = END_TIMES[i].split(":");
|
||||||
"Monday", START_TIMES, END_TIMES, roomIndex);
|
String[] tempStart = START_TIMES[i].split(":");
|
||||||
fillTable(new String[] { "Ts", "Ts", "Ts", "Ts", "Le", "Lunch", "Lunch", "Fh", "Fh", "Fh", "Fh", "" },
|
if (intHour >= Integer.parseInt(tempStart[0]) && intHour <= Integer.parseInt(tempEnd[0])) {
|
||||||
"Tuesday", START_TIMES, END_TIMES, roomIndex);
|
if (intMinute >= Integer.parseInt(tempStart[1])
|
||||||
fillTable(new String[] { "Lu", "Lu", "Lu", "Lu", "Cg", "Cg", "Lunch", "Se", "Se", "Se", "Se", "" },
|
&& intMinute <= Integer.parseInt(tempEnd[1])) {
|
||||||
"Wednesday", START_TIMES, END_TIMES, roomIndex);
|
if (Integer.parseInt(tempEnd[1]) - Integer.parseInt(tempStart[1]) == 5) {
|
||||||
fillTable(new String[] { "Gi", "Gi", "Ba", "Ba", "Ba", "Lunch", "Bd", "Du", "Lz", "Lz" },
|
whatBreak = "short";
|
||||||
"Thursday", START_TIMES, END_TIMES, roomIndex);
|
} else if (Integer.parseInt(tempEnd[1]) - Integer.parseInt(tempStart[1]) > 5) {
|
||||||
fillTable(new String[] { "Kp", "KP", "Or", "Vt", "Vt", "Lunch", "Lunch", "Du", "Du", "Du", "", "" },
|
whatBreak = "long";
|
||||||
"Friday", START_TIMES, END_TIMES, roomIndex);
|
} else {
|
||||||
}
|
whatBreak = "No Break";
|
||||||
|
}
|
||||||
// #region Fill 38
|
|
||||||
static void fill38TimeTable() {
|
|
||||||
int roomIndex = 1;
|
|
||||||
fillTable(new String[] { "Bz", "Bz", "Bz", "Bz", "Bz", "Lunch", "Lunch", "Hn", "Hn", "Bu", "Hn", "Hn" },
|
|
||||||
"Monday", START_TIMES, END_TIMES, roomIndex);
|
|
||||||
fillTable(new String[] { "Kg", "Kg", "Eh", "Re", "Re", "Lunch", "Lunch", "Bt", "Kh", "Kh", "", "" },
|
|
||||||
"Tuesday", START_TIMES, END_TIMES, roomIndex);
|
|
||||||
fillTable(new String[] { "Cg", "Cg", "Cg", "Cg", "Es", "Lunch", "Lunch", "Cg", "Cg", "", "", "" },
|
|
||||||
"Wednesday", START_TIMES, END_TIMES, roomIndex);
|
|
||||||
fillTable(new String[] { "Do", "Do", "Gr", "Gr", "Or", "Lunch", "Lunch", "Bu", "Bu", "Zu", "", "" },
|
|
||||||
"Thursday", START_TIMES, END_TIMES, roomIndex);
|
|
||||||
fillTable(new String[] { "", "Hu", "Ge", "Eh", "Eh", "Bu", "Lunch", "Eh", "Eh", "", "", "" },
|
|
||||||
"Friday", START_TIMES, END_TIMES, roomIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
// #region Fill 39
|
|
||||||
static void fill39TimeTable() {
|
|
||||||
int roomIndex = 2;
|
|
||||||
fillTable(new String[] { "Bd", "Bd", "Bd", "Bd", "Bd", "Lunch", "Lunch", "Lu", "Lu", "Lu", "Lu", "" },
|
|
||||||
"Monday", START_TIMES, END_TIMES, roomIndex);
|
|
||||||
fillTable(new String[] { "Do", "Do", "Zu", "Zu", "Zu", "Lunch", "Lunch", "Se", "Se", "Se", "Se", "" },
|
|
||||||
"Tuesday", START_TIMES, END_TIMES, roomIndex);
|
|
||||||
fillTable(new String[] { "Cg", "Cg", "Cg", "Cg", "Bu", "Lunch", "Lunch", "Gi", "Gi", "Gi", "Gi", "" },
|
|
||||||
"Wednesday", START_TIMES, END_TIMES, roomIndex);
|
|
||||||
fillTable(new String[] { "Bd", "Bd", "Bd", "Bd", "Or", "Lunch", "Lunch", "Le", "Le", "Le", "", "" },
|
|
||||||
"Thursday", START_TIMES, END_TIMES, roomIndex);
|
|
||||||
fillTable(new String[] { "Gi", "Gi", "Gr", "Gr", "Gi", "Lunch", "Lunch", "Hi", "Hi", "Hi", "", "" },
|
|
||||||
"Friday", START_TIMES, END_TIMES, roomIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
static boolean isBreak(int intHour, int intMinute) {
|
|
||||||
// Check if the time is between 7 AM and 5 PM
|
|
||||||
if (intHour >= 7 && intHour <= 17) {
|
|
||||||
// Check if the time falls between any lesson start and end times
|
|
||||||
for (int i = 0; i < START_TIMES.length; i++) {
|
|
||||||
// Split the start and end times into hours and minutes
|
|
||||||
String[] startTime = START_TIMES[i].split(":");
|
|
||||||
String[] endTime = END_TIMES[i].split(":");
|
|
||||||
|
|
||||||
int startHour = Integer.parseInt(startTime[0]);
|
|
||||||
int startMinute = Integer.parseInt(startTime[1]);
|
|
||||||
int endHour = Integer.parseInt(endTime[0]);
|
|
||||||
int endMinute = Integer.parseInt(endTime[1]);
|
|
||||||
|
|
||||||
// Check if the given time is during the current lesson
|
|
||||||
if ((intHour > startHour || (intHour == startHour && intMinute >= startMinute)) &&
|
|
||||||
(intHour < endHour || (intHour == endHour && intMinute < endMinute))) {
|
|
||||||
return false; // It's not a break, it's during a lesson
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true; // If no lessons match, it must be a break
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false; // Time is outside of the school hours (7 AM to 6 PM roughly)
|
}
|
||||||
|
}
|
||||||
|
return whatBreak; // If no break is found, return "No Break"
|
||||||
|
}
|
||||||
|
|
||||||
|
static int[] whatTime(int intHour, int intMinute) {
|
||||||
|
int[] result = new int[2]; // [most recent end time, next start time]
|
||||||
|
result[0] = -1; // Initialize to -1 (no previous end time found)
|
||||||
|
result[1] = -1; // Initialize to -1 (no next start time found)
|
||||||
|
|
||||||
|
for (int i = 0; i < END_TIMES.length; i++) {
|
||||||
|
// Parse END_TIMES[i]
|
||||||
|
String[] endParts = END_TIMES[i].split(":");
|
||||||
|
int endHour = Integer.parseInt(endParts[0]);
|
||||||
|
int endMinute = Integer.parseInt(endParts[1]);
|
||||||
|
|
||||||
|
// Parse START_TIMES[i]
|
||||||
|
String[] startParts = START_TIMES[i].split(":");
|
||||||
|
int startHour = Integer.parseInt(startParts[0]);
|
||||||
|
int startMinute = Integer.parseInt(startParts[1]);
|
||||||
|
|
||||||
|
// Check for the most recent end time
|
||||||
|
if ((intHour > endHour) || (intHour == endHour && intMinute >= endMinute)) {
|
||||||
|
result[0] = i; // Track the most recent lesson's end time index
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for the next start time
|
||||||
|
if ((intHour < startHour) || (intHour == startHour && intMinute < startMinute)) {
|
||||||
|
result[1] = i; // Track the next lesson's start time index
|
||||||
|
break; // No need to continue since START_TIMES is sorted
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static String whatBreakIsIt(int intHour, int intMinute, int intDay) {
|
return result;
|
||||||
boolean isABreak = false;
|
}
|
||||||
for (int i = 0; i < END_TIMES.length; i++) {
|
|
||||||
|
|
||||||
}
|
|
||||||
return "No Break"; // If no break is found, return "No Break"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue