hekp me god

This commit is contained in:
sageTheDM 2024-11-20 13:19:16 +01:00
parent a3f6e8c4dc
commit 1716f0fb17
4 changed files with 86 additions and 60 deletions

View file

@ -75,7 +75,6 @@ public class App {
case "long": case "long":
calculateLongerBreakPoints(data, time, roomNumber); calculateLongerBreakPoints(data, time, roomNumber);
break; break;
default: default:
break; break;
} }
@ -83,6 +82,7 @@ public class App {
} }
} }
// #region 5min
private static int calculateFiveMinuteBreakPoints(List<Co2Data> data, int[] time, int roomNumber) { private static int calculateFiveMinuteBreakPoints(List<Co2Data> data, int[] time, int roomNumber) {
// Calculate the time range for the break (e.g., a 5-minute break) // Calculate the time range for the break (e.g., a 5-minute break)
int startMinute = time[0]; int startMinute = time[0];
@ -117,6 +117,7 @@ public class App {
return Math.max(points, 0); // Ensure that points don't go below zero return Math.max(points, 0); // Ensure that points don't go below zero
} }
// #region 5+ min
private static int calculateLongerBreakPoints(List<Co2Data> data, int[] time, int roomNumber) { private static int calculateLongerBreakPoints(List<Co2Data> data, int[] time, int roomNumber) {
// Take the time for the entire break // Take the time for the entire break
int startMinute = time[0]; int startMinute = time[0];
@ -151,11 +152,12 @@ public class App {
return Math.max(points, 0); // Ensure that points don't go below zero return Math.max(points, 0); // Ensure that points don't go below zero
} }
// #region bonus
private static int calculateBonusPoints(List<Co2Data> data, int[] time, int roomNumber) { private static int calculateBonusPoints(List<Co2Data> data, int[] time, int roomNumber) {
// Check if the next lesson isn't lunch or the same teacher (if the next lesson // Check if the next lesson isn't lunch or the same teacher (if the next lesson
// is lunch, no bonus points possible) // is lunch, no bonus points possible)
boolean isTeacherChange = isTeacherChange(data, roomNumber); // Check if the teacher is changing boolean isTeacherChange = isTeacherChange(data, roomNumber, time); // Check if the teacher is changing
boolean isNextLessonLunch = isNextLessonLunch(data, roomNumber); boolean isNextLessonLunch = FillTable.isNextLessonLunch();
if (!isNextLessonLunch && isTeacherChange) { if (!isNextLessonLunch && isTeacherChange) {
return 5; // Bonus points for teacher switch return 5; // Bonus points for teacher switch
@ -164,15 +166,11 @@ public class App {
} }
} }
private static boolean isTeacherChange(List<Co2Data> data, int roomNumber) { // #region checks
private static boolean isTeacherChange(List<Co2Data> data, int roomNumber, int[] time) {
return false; // Placeholder logic // go through the lesson table of that day and time for the room
} // check if the last teacher in the room equals itself or another teacher
return false; // Placeholder logic (to be implemented based on the timetable)
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) { private static Co2Data getCo2DataForMinute(List<Co2Data> data, int minute) {

View file

@ -84,54 +84,7 @@ public class FillTable {
"Friday", START_TIMES, END_TIMES, roomIndex); "Friday", START_TIMES, END_TIMES, roomIndex);
} }
static boolean isBreak(int intHour, int intMinute) { // #region Check Methods
// 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)
}
static String whatBreakIsIt(int intHour, int intMinute) {
String whatBreak = "";
for (int i = 0; i < END_TIMES.length; i++) {
String[] tempEnd = END_TIMES[i].split(":");
String[] tempStart = START_TIMES[i].split(":");
if (intHour >= Integer.parseInt(tempStart[0]) && intHour <= Integer.parseInt(tempEnd[0])) {
if (intMinute >= Integer.parseInt(tempStart[1])
&& intMinute <= Integer.parseInt(tempEnd[1])) {
if (Integer.parseInt(tempEnd[1]) - Integer.parseInt(tempStart[1]) == 5) {
whatBreak = "short";
} else if (Integer.parseInt(tempEnd[1]) - Integer.parseInt(tempStart[1]) > 5) {
whatBreak = "long";
} else {
whatBreak = "No Break";
}
}
}
}
return whatBreak; // If no break is found, return "No Break"
}
static int[] whatTime(int intHour, int intMinute) { static int[] whatTime(int intHour, int intMinute) {
int[] result = new int[2]; // [most recent end time, next start time] int[] result = new int[2]; // [most recent end time, next start time]
result[0] = -1; // Initialize to -1 (no previous end time found) result[0] = -1; // Initialize to -1 (no previous end time found)
@ -162,4 +115,79 @@ public class FillTable {
return result; return result;
} }
static boolean isNextLessonLunch(int intHour, int intMinute, int roomIndex) {
int currentTimeInMinutes = intHour * 60 + intMinute;
int nextLessonIndex = getNextLessonIndex(currentTimeInMinutes, roomIndex);
if (nextLessonIndex == -1) {
return false;
}
String nextLessonStartTime = START_TIMES[nextLessonIndex];
String[] nextLessonStartParts = nextLessonStartTime.split(":");
int nextLessonStartInMinutes = Integer.parseInt(nextLessonStartParts[0]) * 60
+ Integer.parseInt(nextLessonStartParts[1]);
if (nextLessonStartInMinutes > currentTimeInMinutes) {
String teacherShortName = App.timeTable[roomIndex][getDayIndex("Monday")][nextLessonIndex]
.getTeacherInitials();
return teacherShortName.equals("Lunch");
}
return false;
}
private static int getNextLessonIndex(int currentTimeInMinutes, int roomIndex) {
for (int i = 0; i < START_TIMES.length; i++) {
String[] startParts = START_TIMES[i].split(":");
int startTimeInMinutes = Integer.parseInt(startParts[0]) * 60 + Integer.parseInt(startParts[1]);
if (startTimeInMinutes > currentTimeInMinutes) {
return i;
}
}
return -1;
}
static boolean isBreak(int intHour, int intMinute) {
if (intHour >= 7 && intHour <= 17) {
for (int i = 0; i < START_TIMES.length; i++) {
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]);
if ((intHour > startHour || (intHour == startHour && intMinute >= startMinute)) &&
(intHour < endHour || (intHour == endHour && intMinute < endMinute))) {
return false;
}
}
return true;
}
return false;
}
static String whatBreakIsIt(int intHour, int intMinute) {
String whatBreak = "";
for (int i = 0; i < END_TIMES.length; i++) {
String[] tempEnd = END_TIMES[i].split(":");
String[] tempStart = START_TIMES[i].split(":");
if (intHour >= Integer.parseInt(tempStart[0]) && intHour <= Integer.parseInt(tempEnd[0])) {
if (intMinute >= Integer.parseInt(tempStart[1])
&& intMinute <= Integer.parseInt(tempEnd[1])) {
if (Integer.parseInt(tempEnd[1]) - Integer.parseInt(tempStart[1]) == 5) {
whatBreak = "short";
} else if (Integer.parseInt(tempEnd[1]) - Integer.parseInt(tempStart[1]) > 5) {
whatBreak = "long";
}
}
}
}
return whatBreak;
}
} }