From c317cd6227edbd7b503dc7f0298d568242a22aa1 Mon Sep 17 00:00:00 2001 From: Sage The DM Date: Tue, 29 Oct 2024 20:17:51 +0100 Subject: [PATCH] Start of the Project --- .../CO2-Daten-Projekt/.vscode/settings.json | 7 ++ Code/Steiner/CO2-Daten-Projekt/README.md | 18 ++++ Code/Steiner/CO2-Daten-Projekt/bin/App.class | Bin 0 -> 2328 bytes Code/Steiner/CO2-Daten-Projekt/bin/Data.class | Bin 0 -> 3609 bytes .../CO2-Daten-Projekt/bin/FillTable.class | Bin 0 -> 459 bytes .../CO2-Daten-Projekt/bin/Lesson.class | Bin 0 -> 444 bytes .../CO2-Daten-Projekt/bin/Teacher.class | Bin 0 -> 733 bytes Code/Steiner/CO2-Daten-Projekt/src/App.java | 47 ++++++++++ Code/Steiner/CO2-Daten-Projekt/src/Data.java | 87 ++++++++++++++++++ .../CO2-Daten-Projekt/src/FillTable.java | 28 ++++++ .../Steiner/CO2-Daten-Projekt/src/Lesson.java | 13 +++ .../CO2-Daten-Projekt/src/Teacher.java | 25 +++++ .../src/main/java/com/example/App.java | 12 +-- .../target/classes/com/example/App.class | Bin 1714 -> 1711 bytes 14 files changed, 231 insertions(+), 6 deletions(-) create mode 100644 Code/Steiner/CO2-Daten-Projekt/.vscode/settings.json create mode 100644 Code/Steiner/CO2-Daten-Projekt/README.md create mode 100644 Code/Steiner/CO2-Daten-Projekt/bin/App.class create mode 100644 Code/Steiner/CO2-Daten-Projekt/bin/Data.class create mode 100644 Code/Steiner/CO2-Daten-Projekt/bin/FillTable.class create mode 100644 Code/Steiner/CO2-Daten-Projekt/bin/Lesson.class create mode 100644 Code/Steiner/CO2-Daten-Projekt/bin/Teacher.class create mode 100644 Code/Steiner/CO2-Daten-Projekt/src/App.java create mode 100644 Code/Steiner/CO2-Daten-Projekt/src/Data.java create mode 100644 Code/Steiner/CO2-Daten-Projekt/src/FillTable.java create mode 100644 Code/Steiner/CO2-Daten-Projekt/src/Lesson.java create mode 100644 Code/Steiner/CO2-Daten-Projekt/src/Teacher.java diff --git a/Code/Steiner/CO2-Daten-Projekt/.vscode/settings.json b/Code/Steiner/CO2-Daten-Projekt/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/Steiner/CO2-Daten-Projekt/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/Steiner/CO2-Daten-Projekt/README.md b/Code/Steiner/CO2-Daten-Projekt/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/Steiner/CO2-Daten-Projekt/README.md @@ -0,0 +1,18 @@ +## Getting Started + +Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code. + +## Folder Structure + +The workspace contains two folders by default, where: + +- `src`: the folder to maintain sources +- `lib`: the folder to maintain dependencies + +Meanwhile, the compiled output files will be generated in the `bin` folder by default. + +> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there. + +## Dependency Management + +The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies). diff --git a/Code/Steiner/CO2-Daten-Projekt/bin/App.class b/Code/Steiner/CO2-Daten-Projekt/bin/App.class new file mode 100644 index 0000000000000000000000000000000000000000..e2013f8a04fde645b962937f83415d2aa9accb52 GIT binary patch literal 2328 zcma)8TUQfT6#h;Um=K3sP!s`;mS9LN(Qpw7(khlp8!r`#w)Daw3}Ik0lV&Eg^rb%d z*dO3SU;4yz?P|;7!PS@cp+CvxYWtm;D2ZfsnYAW4`|Q2Hv-h|6K9j%yId}%(8ot#K z5(r-}mo-ELy0+ww%vjPcX6~+S83j)uR&kut*wvfTlho&ZgQ{m*nY`(GIf1rCvuI1N zS}_Dpy{4YYE4SP%%>tOI045Nw1VWo zWLY3G=d2qV^fm~@bsU2((3v-F<4(1-W>jh*@w`)z*0QXa3beM_I^!e75XMOzC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-Projekt/src/App.java new file mode 100644 index 0000000..29ec19d --- /dev/null +++ b/Code/Steiner/CO2-Daten-Projekt/src/App.java @@ -0,0 +1,47 @@ +import java.util.List; + +public class App { + // Fetch data for rooms + private List room39Data = Data.getData("https://api.thingspeak.com/channels/1521262/feeds.csv", 39); + private List room38Data = Data.getData("https://api.thingspeak.com/channels/1364580/feeds.csv", 38); + private List room37Data = Data.getData("https://api.thingspeak.com/channels/1521263/feeds.csv", 37); + + // Time table + // [Room 37 (0), 38 (1), or 39 (2)][Day 0-4][Lesson slot 0-11] + static Lesson[][][] timeTable = new Lesson[3][5][12]; + + public static void main(String[] args) { + fillInTimeTable(); + + // Display filled timetable for verification + for (int room = 0; room < timeTable.length; room++) { + for (int day = 0; day < timeTable[room].length; day++) { + System.out.println("Room " + (room + 37) + ", Day " + (day + 1) + ":"); + for (int lesson = 0; lesson < timeTable[room][day].length; lesson++) { + Lesson lessonData = timeTable[room][day][lesson]; + if (lessonData != null) { + System.out.println(" Lesson " + (lesson + 1) + ": " + lessonData); + } else { + System.out.println(" Lesson " + (lesson + 1) + ": No Lesson"); + } + } + } + } + } + + private static void fillInTimeTable() { + // Fill Room 37 timetable + FillTable.fillRoom37TimeTable(); + + // Fill Room 38 timetable + FillTable.fillRoom38TimeTable(); + + // Fill Room 39 timetable + FillTable.fillRoom39TimeTable(); + + } + + private static void fillRoom37TimeTable() { + + } +} diff --git a/Code/Steiner/CO2-Daten-Projekt/src/Data.java b/Code/Steiner/CO2-Daten-Projekt/src/Data.java new file mode 100644 index 0000000..7e45e80 --- /dev/null +++ b/Code/Steiner/CO2-Daten-Projekt/src/Data.java @@ -0,0 +1,87 @@ +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; + +public class Data { + private int classRomNumber; // either 37 or 38 + private int co2Level; // value in ppm + private String day; // the name of the day + private String date; // example 12.08.2024 + + // Constructor + public Data(int classRomNumber, int co2Level, String day, String date) { + this.classRomNumber = classRomNumber; + this.co2Level = co2Level; + this.day = day; + this.date = date; + } + + // Getters + public int getClassRomNumber() { + return classRomNumber; + } + + public int getCo2Level() { + return co2Level; + } + + public String getDay() { + return day; + } + + public String getDate() { + return date; + } + + public static List getData(String csvURL, int classRomNumber) { + List dataList = new ArrayList<>(); + + try { + URL url = new URL(csvURL); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setRequestMethod("GET"); + conn.setRequestProperty("Accept", "application/csv"); + if (conn.getResponseCode() != 200) { + throw new RuntimeException("Failed : HTTP Error code : " + + conn.getResponseCode()); + } + + InputStreamReader in = new InputStreamReader(conn.getInputStream()); + BufferedReader br = new BufferedReader(in); + String output; + + // Skip header line + br.readLine(); + + while ((output = br.readLine()) != null) { + Data data = parseData(output, classRomNumber); + if (data != null) { + dataList.add(data); + } + } + conn.disconnect(); + + } catch (Exception e) { + System.out.println("Exception in NetClientGet: " + e); + } + + return dataList; // Return the list of Data objects + } + + private static Data parseData(String csvLine, int classRomNumber) { + String[] fields = csvLine.split(","); + if (fields.length < 5) { + return null; // or handle error + } + + String createdAt = fields[0]; // created_at field + int co2Level = Integer.parseInt(fields[2]); // field1 as CO2 level + String date = createdAt.split(" ")[0]; // Extract date + String day = createdAt.split(" ")[0]; // You can implement logic to determine the day from the date if needed + + return new Data(classRomNumber, co2Level, day, date); + } +} diff --git a/Code/Steiner/CO2-Daten-Projekt/src/FillTable.java b/Code/Steiner/CO2-Daten-Projekt/src/FillTable.java new file mode 100644 index 0000000..d64b605 --- /dev/null +++ b/Code/Steiner/CO2-Daten-Projekt/src/FillTable.java @@ -0,0 +1,28 @@ +public class FillTable { + // Fill Room 37 timetable + static void fillRoom37TimeTable() { + // Monday + // Tuesday + // Wednesday + // Thursday + // Friday + } + + // Fill Room 38 timetable + static void fillRoom38TimeTable() { + // Monday + // Tuesday + // Wednesday + // Thursday + // Friday + } + + // Fill Room 39 timetable + static void fillRoom39TimeTable() { + // Monday + // Tuesday + // Wednesday + // Thursday + // Friday + } +} diff --git a/Code/Steiner/CO2-Daten-Projekt/src/Lesson.java b/Code/Steiner/CO2-Daten-Projekt/src/Lesson.java new file mode 100644 index 0000000..bc2a0f4 --- /dev/null +++ b/Code/Steiner/CO2-Daten-Projekt/src/Lesson.java @@ -0,0 +1,13 @@ +public class Lesson { + int room; + String teacherName; + String startTime; + String endTime; + String day; + + public Lesson(int room, String teacherName) { + this.room = room; + this.teacherName = teacherName; + + } +} diff --git a/Code/Steiner/CO2-Daten-Projekt/src/Teacher.java b/Code/Steiner/CO2-Daten-Projekt/src/Teacher.java new file mode 100644 index 0000000..d8323ec --- /dev/null +++ b/Code/Steiner/CO2-Daten-Projekt/src/Teacher.java @@ -0,0 +1,25 @@ +public class Teacher { + private String name; + private int points; + + public Teacher(String name) { + this.name = name; + points = 0; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getPoints() { + return points; + } + + public void setPoints(int points) { + this.points = points; + } +} diff --git a/Code/ost/_05_layouts/src/main/java/com/example/App.java b/Code/ost/_05_layouts/src/main/java/com/example/App.java index 4419fa3..b9dbc2d 100644 --- a/Code/ost/_05_layouts/src/main/java/com/example/App.java +++ b/Code/ost/_05_layouts/src/main/java/com/example/App.java @@ -17,11 +17,11 @@ public class App extends Application { AnchorPane anchorPane = new AnchorPane(); // Create Controll button - Button controlButton = new Button("Button"); - AnchorPane.setTopAnchor(controlButton, 50.0); - AnchorPane.setLeftAnchor(controlButton, 50.0); - AnchorPane.setRightAnchor(controlButton, 10.0); - AnchorPane.setBottomAnchor(controlButton, 10.0); + Button mainButton = new Button("Button"); + AnchorPane.setTopAnchor(mainButton, 50.0); + AnchorPane.setLeftAnchor(mainButton, 50.0); + AnchorPane.setRightAnchor(mainButton, 10.0); + AnchorPane.setBottomAnchor(mainButton, 10.0); // Create Button 1 Button button1 = new Button("Button 1"); @@ -29,7 +29,7 @@ public class App extends Application { AnchorPane.setLeftAnchor(button1, 10.0); // Add buttons to the pane - anchorPane.getChildren().addAll(controlButton, button1); + anchorPane.getChildren().addAll(mainButton, button1); // Set up the Scene with AnchorPane Scene scene = new Scene(anchorPane, 640, 480); diff --git a/Code/ost/_05_layouts/target/classes/com/example/App.class b/Code/ost/_05_layouts/target/classes/com/example/App.class index f1197e9ad8e5c03be29675420bb1b0cc3b95f483..440c9981ff17d34c2b43e291d46ab49d9545e943 100644 GIT binary patch delta 18 ZcmdnQyPkK0APXy3ZenKMW=WQrOaL|E1z-RG delta 21 ccmZ3_yNP#$APWa?a(-S(QGU*5F_xK3086R{zW@LL