pain.exe
This commit is contained in:
		
							parent
							
								
									db6b2a2a6e
								
							
						
					
					
						commit
						58a45463d4
					
				
					 38 changed files with 512 additions and 173 deletions
				
			
		
							
								
								
									
										
											BIN
										
									
								
								Code/Steiner/CO2-Daten-Projekt-V3/src/App.class
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Code/Steiner/CO2-Daten-Projekt-V3/src/App.class
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							|  | @ -1,78 +1,71 @@ | |||
| import java.util.Arrays; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.Scanner; | ||||
| import java.util.HashMap; | ||||
| 
 | ||||
| public class App { | ||||
|     // #region app constants | ||||
|     private static final Scanner scanner = new Scanner(System.in); | ||||
|     private static final Teacher[] teachers = new Teacher[Teacher.nameMap.size()]; | ||||
| 
 | ||||
|     private static final String[] START_SMALL_BREAK = { | ||||
|             "8:30", "10:25", "11:15", "12:05", "13:30", "14:20", "16:10", "17:00", "17:50" | ||||
|     }; | ||||
| 
 | ||||
|     private static final String[] END_SMALL_BREAK = { | ||||
|             "8:35", "10:30", "11:20", "12:10", "13:35", "14:25", "16:15", "17:05", "17:55" | ||||
|     }; | ||||
| 
 | ||||
|     private static final String[] START_LONG_BREAK = { | ||||
|             "9:20", "15:10" | ||||
|     }; | ||||
| 
 | ||||
|     private static final String[] END_LONG_BREAK = { | ||||
|             "9:40", "15:25" | ||||
|     }; | ||||
| 
 | ||||
|     // 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; | ||||
| 
 | ||||
|     // Date and time constants | ||||
|     private static final int START_YEAR = 2024; | ||||
|     private static final int START_MONTH = 11; // November | ||||
|     private static final int START_DAY = 4; | ||||
|     private static final int START_HOUR = 0; | ||||
|     private static final int START_MINUTE = 0; | ||||
| 
 | ||||
|     private static final int END_YEAR = 2024; | ||||
|     private static final int END_MONTH = 11; // November | ||||
|     private static final int END_DAY = 8; | ||||
|     private static final int END_HOUR = 23; | ||||
|     private static final int END_MINUTE = 59; | ||||
| 
 | ||||
|     // Formatting the start and end date with time | ||||
|     private static final String START_DATE = String.format("%d-%02d-%02d%%20%02d:%02d:00", | ||||
|             START_YEAR, START_MONTH, START_DAY, START_HOUR, START_MINUTE); | ||||
|     private static final String END_DATE = String.format("%d-%02d-%02d%%20%02d:%02d:00", | ||||
|             END_YEAR, END_MONTH, END_DAY, END_HOUR, END_MINUTE); | ||||
|     // Date and time constants for Start and End Dates | ||||
|     private static final String START_DATE = "2024-11-04"; | ||||
|     private static final String END_DATE = "2024-11-08"; | ||||
| 
 | ||||
|     // #region Initialization | ||||
|     private static String createUrl(int ROOM_X_NUMBER) { | ||||
|         return String.format("https://api.thingspeak.com/channels/%d/feeds.csv?start=%s&end=%s", | ||||
|                 ROOM_X_NUMBER, START_DATE, END_DATE); | ||||
| 
 | ||||
|     public static String generateLink(int channelNumber, String date, String startTime, String endTime) { | ||||
|         String baseUrl = "https://api.thingspeak.com/channels/"; | ||||
|         String formattedStartDateTime = date + " " + startTime; | ||||
|         String formattedEndDateTime = date + " " + endTime; | ||||
| 
 | ||||
|         return baseUrl + channelNumber + "/feeds.csv?start=" + formattedStartDateTime.replace(" ", "%20") | ||||
|                 + "&end=" + formattedEndDateTime.replace(" ", "%20"); // %20 --> " " | ||||
| 
 | ||||
|     } | ||||
|     // #endregion | ||||
| 
 | ||||
|     private static void getDataForBreak() { | ||||
|         // Co2Data[Wochentag][Room 37, 38 or 39] | ||||
|         Co2Data[][][] data = new Co2Data[5][3][11]; | ||||
|     private static double getDataAverageForMinute(int minute, int hour, int number, String date) { | ||||
|         // get the url | ||||
|         String startTime = ""; | ||||
|         if (hour < 10) { | ||||
|             startTime += "0"; | ||||
|         } | ||||
|         startTime += String.valueOf(hour); | ||||
|         startTime += ":"; | ||||
|         if (minute < 10) { | ||||
|             startTime += "0"; | ||||
|         } | ||||
|         startTime += String.valueOf(minute); | ||||
|         String calcStarttime = startTime + ":00"; | ||||
|         String calcEndTime = startTime + "59"; | ||||
| 
 | ||||
|         // Placeholder logic: Retrieve data for CO2 during breaks | ||||
|         // This should be replaced with the actual logic to get the data from ThingSpeak | ||||
|         for (int i = 0; i < 5; i++) { | ||||
|             for (int j = 0; j < 3; j++) { | ||||
|                 for (int k = 0; k < 11; k++) { | ||||
|                     data[i][j][k] = new Co2Data(null, k); // Placeholder CO2 data | ||||
|         String url = generateLink(number, date, calcStarttime, calcEndTime); | ||||
| 
 | ||||
|         double averageCO2 = 0.0; | ||||
|         List<Co2Data> co2DataList = Co2Data.getData(url); | ||||
|         for (Co2Data co2Data : co2DataList) { | ||||
|             averageCO2 += co2Data.getCo2Level(); | ||||
|         } | ||||
| 
 | ||||
|         return averageCO2 / co2DataList.size(); // Example CO2 average level | ||||
|     } | ||||
| 
 | ||||
|     private static void calculateBreakPoints(double[] minuteData, Break calcBreak) { | ||||
|         int duration = calcBreak.getEnd().getMinute() - calcBreak.getStart().getMinute(); | ||||
|         int breakPoints = minuteData.length; | ||||
|         if (duration == minuteData.length) { | ||||
|             for (int i = 0; i < duration; i++) { | ||||
|                 if (minuteData[i] < minuteData[i + 1]) { | ||||
|                     breakPoints--; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private static double getDataAverageForMinute(String time) { | ||||
|         // Placeholder logic to calculate average CO2 levels | ||||
|         return 400.0; // Example CO2 average level | ||||
|         } else | ||||
|             System.out.println("Unexpected error"); | ||||
|     } | ||||
| 
 | ||||
|     private static void initializeTeachers() { | ||||
|  | @ -85,7 +78,6 @@ public class App { | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private static final Scanner scanner = new Scanner(System.in); | ||||
| 
 | ||||
|     // #region User Interaction | ||||
|     private static int getUserInput(String textOutput) { | ||||
|  | @ -104,7 +96,6 @@ public class App { | |||
|         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("3. 5 bonus points for teacher switches in classrooms."); | ||||
|         System.out.println("4. Deduct points if CO2 levels are too high."); | ||||
|     } | ||||
| 
 | ||||
|     // #region shutdown | ||||
|  | @ -168,15 +159,22 @@ public class App { | |||
|     public static void main(String[] args) { | ||||
|         System.out.println("Calculations in process please do not shut off..."); | ||||
|         initializeTeachers(); | ||||
| 
 | ||||
|         sortTeachers(); | ||||
|         printTeachers(); | ||||
|         // Loop threw each day with a specific classroom and after the weekdays are over | ||||
|         // go to the next of the 3 classroms | ||||
|         // go threw every break calculate the point and give them to the teacher | ||||
|         // directly | ||||
|         // remember the point class | ||||
|         // breakShedule needed | ||||
| 
 | ||||
|         while (true) { | ||||
|             int userInput = getUserInput( | ||||
|                     "Do you want to see how the points were calculated? (Yes 1, No 0; anything is an error)"); | ||||
| 
 | ||||
|             if (userInput == 1) { | ||||
|                 printExplanation(); | ||||
|                 // add a more detailed listing of the teacher since points can be broken down | ||||
|                 // further | ||||
|                 printShutDown(); | ||||
|                 break; | ||||
|             } else if (userInput == 0) { | ||||
|  |  | |||
|  | @ -1,14 +1,10 @@ | |||
| public class Break { | ||||
|     private Time start; | ||||
|     private Time end; | ||||
|     private Teacher teacher; | ||||
|     private int room; | ||||
| 
 | ||||
|     public Break(Time start, Time end, Teacher teacher, int room) { | ||||
|     public Break(Time start, Time end) { | ||||
|         this.start = start; | ||||
|         this.end = end; | ||||
|         this.teacher = teacher; | ||||
|         this.room = room; | ||||
|     } | ||||
| 
 | ||||
|     public Time getStart() { | ||||
|  | @ -27,19 +23,34 @@ public class Break { | |||
|         this.end = end; | ||||
|     } | ||||
| 
 | ||||
|     public Teacher getTeacher() { | ||||
|         return teacher; | ||||
|     /** | ||||
|      * Generates a Thingspeak API link based on channel number, date, and break | ||||
|      * period. | ||||
|      *  | ||||
|      * @param channelNumber The Thingspeak channel number. | ||||
|      * @param date          The date in format "YYYY-MM-DD". | ||||
|      * @param breakPeriod   The Break object containing start and end times. | ||||
|      * @return A formatted URL for fetching data from the Thingspeak API. | ||||
|      */ | ||||
|     public static String generateLink(int channelNumber, String date, Break breakPeriod) { | ||||
|         String baseUrl = "https://api.thingspeak.com/channels/"; | ||||
|         String formattedStartDateTime = date + " " + breakPeriod.getStart().toString(); | ||||
|         String formattedEndDateTime = date + " " + breakPeriod.getEnd().toString(); | ||||
| 
 | ||||
|         return baseUrl + channelNumber + "/feeds.csv?start=" + formattedStartDateTime.replace(" ", "%20") | ||||
|                 + "&end=" + formattedEndDateTime.replace(" ", "%20"); | ||||
|     } | ||||
| 
 | ||||
|     public void setTeacher(Teacher teacher) { | ||||
|         this.teacher = teacher; | ||||
|     } | ||||
|     public static void main(String[] args) { | ||||
|         // Example usage | ||||
|         Time start = Time.valueOf("00:00:00"); | ||||
|         Time end = Time.valueOf("23:59:59"); | ||||
|         Break breakPeriod = new Break(start, end); | ||||
| 
 | ||||
|     public int getRoom() { | ||||
|         return room; | ||||
|     } | ||||
|         String date = "2024-11-17"; | ||||
|         int channelNumber = 1364580; | ||||
| 
 | ||||
|     public void setRoom(int room) { | ||||
|         this.room = room; | ||||
|         String link = Break.generateLink(channelNumber, date, breakPeriod); | ||||
|         System.out.println(link); | ||||
|     } | ||||
| } | ||||
|  |  | |||
							
								
								
									
										47
									
								
								Code/Steiner/CO2-Daten-Projekt-V3/src/BreakSchedule.java
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								Code/Steiner/CO2-Daten-Projekt-V3/src/BreakSchedule.java
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,47 @@ | |||
| public class BreakSchedule { | ||||
|     private static final String[] START_SMALL_BREAK = { | ||||
|             "8:30", "10:25", "11:15", "12:05", "13:30", "14:20", "16:10", "17:00", "17:50" | ||||
|     }; | ||||
| 
 | ||||
|     private static final String[] END_SMALL_BREAK = { | ||||
|             "8:35", "10:30", "11:20", "12:10", "13:35", "14:25", "16:15", "17:05", "17:55" | ||||
|     }; | ||||
| 
 | ||||
|     private static final String[] START_LONG_BREAK = { | ||||
|             "9:20", "15:10" | ||||
|     }; | ||||
| 
 | ||||
|     private static final String[] END_LONG_BREAK = { | ||||
|             "9:40", "15:25" | ||||
|     }; | ||||
| 
 | ||||
|     private static final Break[] SMALL_BREAKS; | ||||
|     private static final Break[] LONG_BREAKS; | ||||
| 
 | ||||
|     static { | ||||
|         SMALL_BREAKS = createBreaks(START_SMALL_BREAK, END_SMALL_BREAK); | ||||
|         LONG_BREAKS = createBreaks(START_LONG_BREAK, END_LONG_BREAK); | ||||
|     } | ||||
| 
 | ||||
|     private static Break[] createBreaks(String[] startTimes, String[] endTimes) { | ||||
|         Break[] breaks = new Break[startTimes.length]; | ||||
|         for (int i = 0; i < startTimes.length; i++) { | ||||
|             // Append ":00" to include seconds | ||||
|             String startTimeWithSeconds = startTimes[i]; | ||||
|             String endTimeWithSeconds = endTimes[i]; | ||||
| 
 | ||||
|             Time start = Time.valueOf(startTimeWithSeconds); | ||||
|             Time end = Time.valueOf(endTimeWithSeconds); | ||||
|             breaks[i] = new Break(start, end); | ||||
|         } | ||||
|         return breaks; | ||||
|     } | ||||
| 
 | ||||
|     public static Break[] getSmallBreaks() { | ||||
|         return SMALL_BREAKS; | ||||
|     } | ||||
| 
 | ||||
|     public static Break[] getLongBreaks() { | ||||
|         return LONG_BREAKS; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										
											BIN
										
									
								
								Code/Steiner/CO2-Daten-Projekt-V3/src/Co2Data.class
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Code/Steiner/CO2-Daten-Projekt-V3/src/Co2Data.class
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							|  | @ -2,21 +2,22 @@ import java.io.BufferedReader; | |||
| import java.io.InputStreamReader; | ||||
| import java.net.HttpURLConnection; | ||||
| import java.net.URL; | ||||
| import java.text.SimpleDateFormat; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Date; | ||||
| import java.util.List; | ||||
| 
 | ||||
| public class Co2Data { | ||||
|     // #region Fields | ||||
|     private Date date; | ||||
|     private int co2Level; | ||||
| 
 | ||||
|     // #region Constructor | ||||
|     // Constructor | ||||
|     public Co2Data(Date date, int co2Level) { | ||||
|         this.date = date; | ||||
|         this.co2Level = co2Level; | ||||
|     } | ||||
| 
 | ||||
|     // #region Getters and Setters | ||||
|     // Getters and Setters | ||||
|     public Date getDate() { | ||||
|         return date; | ||||
|     } | ||||
|  | @ -33,17 +34,15 @@ public class Co2Data { | |||
|         this.co2Level = co2Level; | ||||
|     } | ||||
| 
 | ||||
|     // #region Data Fetching | ||||
|     // Method to fetch and parse CO2 data from a URL | ||||
|     public static List<Co2Data> getData(String csvURL, int classRoomNumber) { | ||||
|     // Fetch and parse data from a CSV URL | ||||
|     public static List<Co2Data> getData(String csvURL) { | ||||
|         List<Co2Data> dataList = new ArrayList<>(); | ||||
|         Date referenceDate = new Date(8, 11, 2024, 0, 0); // Reference date: November 8, 2024 | ||||
| 
 | ||||
|         try { | ||||
|             URL url = new URL(csvURL); | ||||
|             HttpURLConnection conn = (HttpURLConnection) url.openConnection(); | ||||
|             conn.setRequestMethod("GET"); | ||||
|             conn.setRequestProperty("Accept", "application/csv"); | ||||
|             conn.setRequestProperty("Accept", "text/csv"); | ||||
| 
 | ||||
|             if (conn.getResponseCode() != 200) { | ||||
|                 throw new RuntimeException("Failed : HTTP Error code : " + conn.getResponseCode()); | ||||
|  | @ -54,66 +53,36 @@ public class Co2Data { | |||
| 
 | ||||
|             String output; | ||||
|             while ((output = br.readLine()) != null) { | ||||
|                 Co2Data data = parseData(output, classRoomNumber); | ||||
|                 if (data != null && isNewerThanReferenceDate(data.getDate(), referenceDate)) { | ||||
|                 Co2Data data = parseData(output); | ||||
|                 if (data != null) { | ||||
|                     dataList.add(data); | ||||
|                 } | ||||
|             } | ||||
|             conn.disconnect(); | ||||
| 
 | ||||
|         } catch (Exception e) { | ||||
|             System.out.println("Exception in NetClientGet: " + e); | ||||
|             System.out.println("Error in data fetching: " + e); | ||||
|         } | ||||
| 
 | ||||
|         return dataList; | ||||
|     } | ||||
| 
 | ||||
|     // #region Date Comparison | ||||
|     // Method to compare if the data date is newer than the reference date | ||||
|     private static boolean isNewerThanReferenceDate(Date dataDate, Date referenceDate) { | ||||
|         if (dataDate.getYear() > referenceDate.getYear()) { | ||||
|             return true; | ||||
|         } else if (dataDate.getYear() == referenceDate.getYear()) { | ||||
|             if (dataDate.getMonth() > referenceDate.getMonth()) { | ||||
|                 return true; | ||||
|             } else if (dataDate.getMonth() == referenceDate.getMonth()) { | ||||
|                 return dataDate.getDay() > referenceDate.getDay(); | ||||
|             } | ||||
|         } | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     // #region Data Parsing | ||||
|     // Method to parse CO2 data from a CSV line | ||||
|     private static Co2Data parseData(String csvLine, int classRoomNumber) { | ||||
|         String[] fields = csvLine.split(","); | ||||
|         if (fields.length < 5) | ||||
|             return null; | ||||
| 
 | ||||
|     // Helper method to parse CSV data and create a Co2Data object | ||||
|     private static Co2Data parseData(String line) { | ||||
|         try { | ||||
|             String[] dateTime = fields[0].split(" "); | ||||
|             String[] dateParts = dateTime[0].split("-"); | ||||
|             String[] timeParts = dateTime[1].split(":"); | ||||
|             String[] parts = line.split(","); | ||||
|             String dateStr = parts[0].trim(); // assuming date is in the first column | ||||
|             int co2Level = Integer.parseInt(parts[1].trim()); // assuming CO2 level is in the second column | ||||
| 
 | ||||
|             int year = Integer.parseInt(dateParts[0]); | ||||
|             int month = Integer.parseInt(dateParts[1]); | ||||
|             int day = Integer.parseInt(dateParts[2]); | ||||
|             int hour = Integer.parseInt(timeParts[0]); | ||||
|             int minute = Integer.parseInt(timeParts[1]); | ||||
|             Date date = new Date(day, month, year, hour, minute); | ||||
| 
 | ||||
|             int co2Level = Integer.parseInt(fields[2]); | ||||
|             // Convert the date string into a Date object (assumes CSV date format is | ||||
|             // yyyy-MM-dd HH:mm:ss) | ||||
|             SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||||
|             Date date = sdf.parse(dateStr); | ||||
| 
 | ||||
|             return new Co2Data(date, co2Level); | ||||
|         } catch (NumberFormatException e) { | ||||
|         } catch (Exception e) { | ||||
|             System.out.println("Error parsing data line: " + e); | ||||
|             return null; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     // #region ToString Method | ||||
|     // Method to return a string representation of the CO2 data | ||||
|     @Override | ||||
|     public String toString() { | ||||
|         return "Date: " + date + ", CO2 Level: " + co2Level; | ||||
|     } | ||||
| } | ||||
|  |  | |||
							
								
								
									
										
											BIN
										
									
								
								Code/Steiner/CO2-Daten-Projekt-V3/src/Date.class
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Code/Steiner/CO2-Daten-Projekt-V3/src/Date.class
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							|  | @ -1,34 +1,62 @@ | |||
| public class Date { | ||||
|     // #region Fields | ||||
|     private int day; | ||||
|     private int month; | ||||
|     private int year; | ||||
|     private int month; | ||||
|     private int day; | ||||
|     private int hour; | ||||
|     private int minute; | ||||
| 
 | ||||
|     // #region Constructor | ||||
|     public Date(int day, int month, int year, int hour, int minute) { | ||||
|         this.day = day; | ||||
|         this.month = month; | ||||
|         this.year = year; | ||||
|         this.hour = hour; | ||||
|         this.minute = minute; | ||||
|     // Constructor to parse date string | ||||
|     public Date(String dateStr) { | ||||
|         String[] dateTime = dateStr.split(" "); | ||||
|         String[] dateParts = dateTime[0].split("-"); | ||||
|         String[] timeParts = dateTime[1].split(":"); | ||||
| 
 | ||||
|         // Automatically adjust for Switzerland time after initialization | ||||
|         this.year = Integer.parseInt(dateParts[0]); | ||||
|         this.month = Integer.parseInt(dateParts[1]); | ||||
|         this.day = Integer.parseInt(dateParts[2]); | ||||
|         this.hour = Integer.parseInt(timeParts[0]); | ||||
|         this.minute = Integer.parseInt(timeParts[1]); | ||||
| 
 | ||||
|         // Adjust for Switzerland time | ||||
|         adjustForSwitzerlandTime(); | ||||
|     } | ||||
| 
 | ||||
|     // #region Getters | ||||
|     public int getDay() { | ||||
|         return day; | ||||
|     // Constructor to create date with fixed numeric values | ||||
|     public Date(int year, int month, int day, int hour, int minute) { | ||||
|         this.year = year; | ||||
|         this.month = month; | ||||
|         this.day = day; | ||||
|         this.hour = hour; | ||||
|         this.minute = minute; | ||||
| 
 | ||||
|         // Adjust for Switzerland time | ||||
|         adjustForSwitzerlandTime(); | ||||
|     } | ||||
| 
 | ||||
|     // Adjust time for Switzerland timezone (UTC+1 or UTC+2 during daylight saving | ||||
|     // time) | ||||
|     private void adjustForSwitzerlandTime() { | ||||
|         // Switzerland time adjustment logic (simplified version) | ||||
|         // For simplicity, this doesn't handle daylight saving time changes but adjusts | ||||
|         // based on UTC+1 | ||||
|         this.hour += 1; // Assuming fixed UTC+1 offset for simplicity | ||||
|         if (this.hour >= 24) { | ||||
|             this.hour -= 24; | ||||
|             this.day += 1; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     // Getter methods | ||||
|     public int getYear() { | ||||
|         return year; | ||||
|     } | ||||
| 
 | ||||
|     public int getMonth() { | ||||
|         return month; | ||||
|     } | ||||
| 
 | ||||
|     public int getYear() { | ||||
|         return year; | ||||
|     public int getDay() { | ||||
|         return day; | ||||
|     } | ||||
| 
 | ||||
|     public int getHour() { | ||||
|  | @ -39,38 +67,7 @@ public class Date { | |||
|         return minute; | ||||
|     } | ||||
| 
 | ||||
|     // #region Adjust UTC to Switzerland Time | ||||
|     private void adjustForSwitzerlandTime() { | ||||
|         hour += 1; | ||||
| 
 | ||||
|         // Adjust if the hour exceeds 24 or falls below 0 | ||||
|         if (hour >= 24) { | ||||
|             hour -= 24; | ||||
|             day++; | ||||
|             if (day > 31) { // Simple month/day rollover, could be more sophisticated | ||||
|                 day = 1; | ||||
|                 month++; | ||||
|                 if (month > 12) { | ||||
|                     month = 1; | ||||
|                     year++; | ||||
|                 } | ||||
|             } | ||||
|         } else if (hour < 0) { | ||||
|             hour += 24; | ||||
|             day--; | ||||
|             if (day < 1) { | ||||
|                 month--; | ||||
|                 if (month < 1) { | ||||
|                     month = 12; | ||||
|                     year--; | ||||
|                 } | ||||
|                 day = 31; // Simple month/day rollover, could be more sophisticated | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     // #region toString Override | ||||
|     @Override | ||||
|     // Method to print date in a readable format | ||||
|     public String toString() { | ||||
|         return String.format("%04d-%02d-%02d %02d:%02d", year, month, day, hour, minute); | ||||
|     } | ||||
|  |  | |||
							
								
								
									
										
											BIN
										
									
								
								Code/Steiner/CO2-Daten-Projekt-V3/src/Points.class
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Code/Steiner/CO2-Daten-Projekt-V3/src/Points.class
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Code/Steiner/CO2-Daten-Projekt-V3/src/Teacher.class
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Code/Steiner/CO2-Daten-Projekt-V3/src/Teacher.class
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							|  | @ -26,4 +26,12 @@ public class Time { | |||
|     public void setMinute(int minute) { | ||||
|         this.minute = minute; | ||||
|     } | ||||
| 
 | ||||
|     public static Time valueOf(String time) { | ||||
|         String[] parts = time.split(":"); | ||||
|         int hour = Integer.parseInt(parts[0]); | ||||
|         int minute = Integer.parseInt(parts[1]); | ||||
|         Time returnValue = new Time(hour, minute); | ||||
|         return returnValue; | ||||
|     } | ||||
| } | ||||
|  |  | |||
							
								
								
									
										79
									
								
								Code/Steiner/CO2-Daten-Projekt-V3/src/TimeTable.java
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										79
									
								
								Code/Steiner/CO2-Daten-Projekt-V3/src/TimeTable.java
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,79 @@ | |||
| public class TimeTable { | ||||
|     private String[][] shortTeacher; | ||||
| 
 | ||||
|     public TimeTable(int roomIndex) { | ||||
|         shortTeacher = new String[11][5]; // 11 lessons, 5 weekdays | ||||
|         initializeTimeTable(roomIndex); | ||||
|     } | ||||
| 
 | ||||
|     private void initializeTimeTable(int roomIndex) { | ||||
|         switch (roomIndex) { | ||||
|             case 0: // Room 37 | ||||
|                 fillRoom37(); | ||||
|                 break; | ||||
|             case 1: // Room 38 | ||||
|                 fillRoom38(); | ||||
|                 break; | ||||
|             case 2: // Room 39 | ||||
|                 fillRoom39(); | ||||
|                 break; | ||||
|             default: | ||||
|                 throw new IllegalArgumentException("Invalid room index"); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private void fillRoom37() { | ||||
|         shortTeacher = new String[][] { | ||||
|                 { "Hm", "Ts", "Lu", "Gi", "Kp" }, | ||||
|                 { "Hm", "Ts", "Lu", "Gi", "KP" }, | ||||
|                 { "Hi", "Ts", "Lu", "Ba", "Or" }, | ||||
|                 { "Hm", "Ts", "Lu", "Ba", "Vt" }, | ||||
|                 { "Hm", "Le", "Cg", "Ba", "Vt" }, | ||||
|                 { "Lunch", "Lunch", "Lunch", "Lunch", "Lunch" }, | ||||
|                 { "Bd", "Lunch", "Se", "Bd", "Lunch" }, | ||||
|                 { "Gi", "Fh", "Se", "Du", "Du" }, | ||||
|                 { "Gi", "Fh", "Se", "Lz", "Du" }, | ||||
|                 { "Ts", "Fh", "Se", "Lz", "Du" }, | ||||
|                 { "Ts", "Fh", "Se", "", "" } | ||||
|         }; | ||||
|     } | ||||
| 
 | ||||
|     private void fillRoom38() { | ||||
|         shortTeacher = new String[][] { | ||||
|                 { "Bz", "Kg", "Cg", "Do", "" }, | ||||
|                 { "Bz", "Kg", "Cg", "Do", "Hu" }, | ||||
|                 { "Bz", "Eh", "Cg", "Gr", "Ge" }, | ||||
|                 { "Bz", "Re", "Cg", "Gr", "Eh" }, | ||||
|                 { "Bz", "Re", "Es", "Or", "Eh" }, | ||||
|                 { "Lunch", "Lunch", "Lunch", "Lunch", "Lunch" }, | ||||
|                 { "Lunch", "Lunch", "Lunch", "Lunch", "Bu" }, | ||||
|                 { "Hn", "Bt", "Cg", "Bu", "Eh" }, | ||||
|                 { "Hn", "Kh", "Cg", "Bu", "Eh" }, | ||||
|                 { "Bu", "Kh", "", "Zu", "" }, | ||||
|                 { "Hn", "", "", "", "" } | ||||
|         }; | ||||
|     } | ||||
| 
 | ||||
|     private void fillRoom39() { | ||||
|         shortTeacher = new String[][] { | ||||
|                 { "Bd", "Do", "Cg", "Bd", "Gi" }, | ||||
|                 { "Bd", "Do", "Cg", "Bd", "Gi" }, | ||||
|                 { "Bd", "Zu", "Cg", "Bd", "Gr" }, | ||||
|                 { "Bd", "Zu", "Cg", "Bd", "Gr" }, | ||||
|                 { "Bd", "Zu", "Bu", "Or", "Gi" }, | ||||
|                 { "Lunch", "Lunch", "Lunch", "Lunch", "Lunch" }, | ||||
|                 { "Lunch", "Lunch", "Lunch", "Lunch", "Lunch" }, | ||||
|                 { "Lu", "Se", "Gi", "Le", "Hi" }, | ||||
|                 { "Lu", "Se", "Gi", "Le", "Hi" }, | ||||
|                 { "Lu", "Se", "Gi", "Le", "Hi" }, | ||||
|                 { "Lu", "Se", "Gi", "", "" } | ||||
|         }; | ||||
|     } | ||||
| 
 | ||||
|     public String getLesson(int lesson, int day) { | ||||
|         if (lesson < 0 || lesson >= 11 || day < 0 || day >= 5) { | ||||
|             throw new IllegalArgumentException("Invalid lesson or day"); | ||||
|         } | ||||
|         return shortTeacher[lesson][day]; | ||||
|     } | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Sage The DM
						Sage The DM