diff --git a/Code/Steiner/CO2-Daten-Projekt-V2/.vscode/settings.json b/Code/Steiner/CO2-Daten-Projekt-V2/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/Steiner/CO2-Daten-Projekt-V2/.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-V2/README.md b/Code/Steiner/CO2-Daten-Projekt-V2/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/Steiner/CO2-Daten-Projekt-V2/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-V2/bin/App.class b/Code/Steiner/CO2-Daten-Projekt-V2/bin/App.class new file mode 100644 index 0000000..52e0619 Binary files /dev/null and b/Code/Steiner/CO2-Daten-Projekt-V2/bin/App.class differ diff --git a/Code/Steiner/CO2-Daten-Projekt-V2/bin/Co2Data.class b/Code/Steiner/CO2-Daten-Projekt-V2/bin/Co2Data.class new file mode 100644 index 0000000..428ebcc Binary files /dev/null and b/Code/Steiner/CO2-Daten-Projekt-V2/bin/Co2Data.class differ diff --git a/Code/Steiner/CO2-Daten-Projekt-V2/bin/Date.class b/Code/Steiner/CO2-Daten-Projekt-V2/bin/Date.class new file mode 100644 index 0000000..407dda6 Binary files /dev/null and b/Code/Steiner/CO2-Daten-Projekt-V2/bin/Date.class differ diff --git a/Code/Steiner/CO2-Daten-Projekt-V2/bin/FillTable.class b/Code/Steiner/CO2-Daten-Projekt-V2/bin/FillTable.class new file mode 100644 index 0000000..bbcabff Binary files /dev/null and b/Code/Steiner/CO2-Daten-Projekt-V2/bin/FillTable.class differ diff --git a/Code/Steiner/CO2-Daten-Projekt-V2/bin/Lesson.class b/Code/Steiner/CO2-Daten-Projekt-V2/bin/Lesson.class new file mode 100644 index 0000000..83e9051 Binary files /dev/null and b/Code/Steiner/CO2-Daten-Projekt-V2/bin/Lesson.class differ diff --git a/Code/Steiner/CO2-Daten-Projekt-V2/bin/Points.class b/Code/Steiner/CO2-Daten-Projekt-V2/bin/Points.class new file mode 100644 index 0000000..3b15870 Binary files /dev/null and b/Code/Steiner/CO2-Daten-Projekt-V2/bin/Points.class differ diff --git a/Code/Steiner/CO2-Daten-Projekt-V2/bin/Teacher.class b/Code/Steiner/CO2-Daten-Projekt-V2/bin/Teacher.class new file mode 100644 index 0000000..f42ed1f Binary files /dev/null and b/Code/Steiner/CO2-Daten-Projekt-V2/bin/Teacher.class differ diff --git a/Code/Steiner/CO2-Daten-Projekt-V2/src/App.java b/Code/Steiner/CO2-Daten-Projekt-V2/src/App.java new file mode 100644 index 0000000..8a24371 --- /dev/null +++ b/Code/Steiner/CO2-Daten-Projekt-V2/src/App.java @@ -0,0 +1,112 @@ +import java.util.Arrays; +import java.util.Scanner; + +public class App { + private static final Scanner scanner = new Scanner(System.in); + + private static final int ROOM_COUNT = 3; + private static final int DAY_COUNT = 5; + private static final int LESSON_COUNT = 12; + + 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 void initializeTeachers() { + int index = 0; + for (String initial : Teacher.nameMap.keySet()) { + teachers[index++] = new Teacher(initial); + } + } + + private static void fillInTimeTable() { + FillTable.fill37TimeTable(); + FillTable.fill38TimeTable(); + FillTable.fill39TimeTable(); + } + + private static void calculatePoints() { + // Point calculation logic + } + + private static void sortTeachers() { + Arrays.sort(teachers, + (a, b) -> Integer.compare(b.getPoints().getTotalPoints(), a.getPoints().getTotalPoints())); + } + + private static void printTeachers() { + int rank = 1; + int previousPoints = -1; + int currentRank = 1; + + for (int i = 0; i < teachers.length; i++) { + Teacher teacher = teachers[i]; + int teacherPoints = teacher.getPoints().getTotalPoints(); + + if (teacherPoints == previousPoints) { + System.out.println(currentRank + ". " + teacher.getName() + " " + teacherPoints); + } else { + if (i > 0) { + rank += (i - (currentRank - 1)); + } + currentRank = rank; + System.out.println(rank + ". " + teacher.getName() + " " + teacherPoints); + } + + previousPoints = teacherPoints; + } + } + + private static int getUserInput(String textOutput) { + System.out.println(textOutput); + while (true) { + if (scanner.hasNextInt()) { + return scanner.nextInt(); + } else { + System.out.println("Invalid input. Please enter a number."); + scanner.next(); + } + } + } + + private static void printExplanation() { + System.out.println("Point calculation explanation:"); + System.out.println("1. Up to 5 points for keeping the window open during a small break."); + System.out.println("2. Up to 10 points for long breaks, depending on window usage."); + System.out.println("3. 5 bonus points for teacher switches in the room."); + } + + private static void printShutDown() { + System.out.println("Shutting down..."); + for (int i = 3; i > 0; i--) { + System.out.print(i + "..."); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + } + System.out.println("Goodbye!"); + } + + public static void main(String[] args) { + fillInTimeTable(); + initializeTeachers(); + calculatePoints(); + sortTeachers(); + printTeachers(); + + 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(); + printShutDown(); + } else if (userInput == 0) { + printShutDown(); + } else { + System.out.println("Invalid input. Please enter 1 for Yes or 0 for No."); + } + + scanner.close(); + } +} diff --git a/Code/Steiner/CO2-Daten-Projekt-V2/src/Co2Data.java b/Code/Steiner/CO2-Daten-Projekt-V2/src/Co2Data.java new file mode 100644 index 0000000..33c649f --- /dev/null +++ b/Code/Steiner/CO2-Daten-Projekt-V2/src/Co2Data.java @@ -0,0 +1,98 @@ +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 Co2Data { + private Date date; + private int co2Level; + + public Co2Data(Date date, int co2Level) { + this.date = date; + this.co2Level = co2Level; + } + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } + + public int getCo2Level() { + return co2Level; + } + + public void setCo2Level(int co2Level) { + this.co2Level = co2Level; + } + + public static List getData(String csvURL, int classRoomNumber) { + 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) { + Co2Data data = parseData(output, classRoomNumber); + if (data != null) { + dataList.add(data); + } + } + conn.disconnect(); + + } catch (Exception e) { + System.out.println("Exception in NetClientGet: " + e); + } + + return dataList; // Return the list of Co2Data objects + } + + private static Co2Data parseData(String csvLine, int classRoomNumber) { + String[] fields = csvLine.split(","); + if (fields.length < 5) { + return null; // Handle error or log it if needed + } + + try { + // Extract date and time from created_at field + String createdAt = fields[0]; + String[] dateTime = createdAt.split(" "); + String[] dateParts = dateTime[0].split("-"); + String[] timeParts = dateTime[1].split(":"); + + // Create a Date object + 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); + + // Parse CO2 level (field1) + int co2Level = Integer.parseInt(fields[2]); + + return new Co2Data(date, co2Level); + } catch (Exception e) { + System.out.println("Error parsing data: " + e); + return null; + } + } +} diff --git a/Code/Steiner/CO2-Daten-Projekt-V2/src/Date.java b/Code/Steiner/CO2-Daten-Projekt-V2/src/Date.java new file mode 100644 index 0000000..12377bb --- /dev/null +++ b/Code/Steiner/CO2-Daten-Projekt-V2/src/Date.java @@ -0,0 +1,41 @@ +public class Date { + private int day; + private int month; + private int year; + private int hour; + private int minute; + + 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; + } + + // Getters + public int getDay() { + return day; + } + + public int getMonth() { + return month; + } + + public int getYear() { + return year; + } + + public int getHour() { + return hour; + } + + public int getMinute() { + return minute; + } + + @Override + public String toString() { + return String.format("%04d-%02d-%02d %02d:%02d", year, month, day, hour, minute); + } +} diff --git a/Code/Steiner/CO2-Daten-Projekt-V2/src/FillTable.java b/Code/Steiner/CO2-Daten-Projekt-V2/src/FillTable.java new file mode 100644 index 0000000..adf9696 --- /dev/null +++ b/Code/Steiner/CO2-Daten-Projekt-V2/src/FillTable.java @@ -0,0 +1,81 @@ + +public class FillTable { + private static final String[] START_TIMES = { + "7:45", "8:35", "9:40", "10:30", "11:20", "12:10", "12:50", + "13:35", "14:25", "15:15", "16:15", "17:05" + }; + + private static final String[] END_TIMES = { + "8:30", "9:20", "10:25", "11:15", "12:05", "12:50", "13:30", + "14:20", "15:10", "16:10", "17:00", "17:50" + }; + + private static void fillTable(String[] teacherShortNames, String day, String[] startTime, String[] endTime, + int roomIndex) { + int dayIndex = getDayIndex(day); + for (int i = 0; i < teacherShortNames.length && i < startTime.length && i < endTime.length; i++) { + Teacher teacher = new Teacher(teacherShortNames[i]); // Initialize Teacher with shortform + App.timeTable[roomIndex][dayIndex][i] = new Lesson(roomIndex, teacher.getName(), startTime[i], endTime[i], + 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; + } + } + + 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); + } + + 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); + } + + 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); + } +} \ No newline at end of file diff --git a/Code/Steiner/CO2-Daten-Projekt-V2/src/Lesson.java b/Code/Steiner/CO2-Daten-Projekt-V2/src/Lesson.java new file mode 100644 index 0000000..fd4d6bc --- /dev/null +++ b/Code/Steiner/CO2-Daten-Projekt-V2/src/Lesson.java @@ -0,0 +1,37 @@ +public class Lesson { + private int roomNumberNumber; + private String teacherInitials; + private String startTime; + private String endTime; + private String weekweekDay; + + // Constructor to initialize all fields + public Lesson(int roomNumber, String teacherInitials, String startTime, String endTime, String weekweekDay) { + this.roomNumberNumber = roomNumber; + this.teacherInitials = teacherInitials; + this.startTime = startTime; + this.endTime = endTime; + this.weekweekDay = weekweekDay; + } + + // Getters + public int getroomNumber() { + return roomNumberNumber; + } + + public String getteacherInitials() { + return teacherInitials; + } + + public String getStartTime() { + return startTime; + } + + public String getEndTime() { + return endTime; + } + + public String getweekDay() { + return weekweekDay; + } +} \ No newline at end of file diff --git a/Code/Steiner/CO2-Daten-Projekt-V2/src/Points.java b/Code/Steiner/CO2-Daten-Projekt-V2/src/Points.java new file mode 100644 index 0000000..490549d --- /dev/null +++ b/Code/Steiner/CO2-Daten-Projekt-V2/src/Points.java @@ -0,0 +1,35 @@ +// Points class for managing point categories +public class Points { + private int fiveMinuteBreak; + private int longerBreak; + private int bonusPoints; + + public int getFiveMinuteBreak() { + return fiveMinuteBreak; + } + + public void setFiveMinuteBreak(int fiveMinuteBreak) { + this.fiveMinuteBreak = fiveMinuteBreak; + } + + public int getLongerBreak() { + return longerBreak; + } + + public void setLongerBreak(int longerBreak) { + this.longerBreak = longerBreak; + } + + public int getBonusPoints() { + return bonusPoints; + } + + public void setBonusPoints(int bonusPoints) { + this.bonusPoints = bonusPoints; + } + + // Method to calculate total points + public int getTotalPoints() { + return fiveMinuteBreak + longerBreak + bonusPoints; + } +} \ No newline at end of file diff --git a/Code/Steiner/CO2-Daten-Projekt-V2/src/Teacher.java b/Code/Steiner/CO2-Daten-Projekt-V2/src/Teacher.java new file mode 100644 index 0000000..6802f61 --- /dev/null +++ b/Code/Steiner/CO2-Daten-Projekt-V2/src/Teacher.java @@ -0,0 +1,44 @@ +import java.util.HashMap; +import java.util.Map; + +public class Teacher { + private String name; + private Points points; + + public static final Map nameMap = new HashMap<>(); + static { + nameMap.put("Hm", "Hummel"); + nameMap.put("Bd", "Bender"); + nameMap.put("Bu", "Burger"); + nameMap.put("Cg", "Chung"); + nameMap.put("Do", "Doe"); + nameMap.put("Eh", "Ehrlich"); + nameMap.put("Fh", "Fischer"); + nameMap.put("Gi", "Giordano"); + nameMap.put("Gr", "Graham"); + nameMap.put("Hi", "Higgins"); + nameMap.put("Kg", "Kang"); + nameMap.put("Kh", "Khan"); + nameMap.put("Lz", "Lozano"); + nameMap.put("Lu", "Lund"); + nameMap.put("Or", "Ortega"); + nameMap.put("Re", "Reyes"); + nameMap.put("Se", "Seng"); + nameMap.put("Ts", "Tanaka"); + nameMap.put("Vt", "Vetter"); + nameMap.put("Zu", "Zuniga"); + } + + public Teacher(String name) { + this.name = nameMap.getOrDefault(name, "Unknown"); + this.points = new Points(); + } + + public String getName() { + return name; + } + + public Points getPoints() { + return points; + } +} diff --git a/Code/Steiner/arrayList/.vscode/settings.json b/Code/Steiner/arrayList/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/Steiner/arrayList/.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/arrayList/README.md b/Code/Steiner/arrayList/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/Steiner/arrayList/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/arrayList/bin/App.class b/Code/Steiner/arrayList/bin/App.class new file mode 100644 index 0000000..5fe6494 Binary files /dev/null and b/Code/Steiner/arrayList/bin/App.class differ diff --git a/Code/Steiner/arrayList/src/App.class b/Code/Steiner/arrayList/src/App.class new file mode 100644 index 0000000..5ae6d78 Binary files /dev/null and b/Code/Steiner/arrayList/src/App.class differ diff --git a/Code/Steiner/arrayList/src/App.java b/Code/Steiner/arrayList/src/App.java new file mode 100644 index 0000000..3a5a17c --- /dev/null +++ b/Code/Steiner/arrayList/src/App.java @@ -0,0 +1,71 @@ +import java.util.ArrayList; +import java.util.Collections; + +public class App { + public static void main(String[] args) { + int[] array = { 0, 1, 2, 3, 4, 5, 4, -3, -2, 0 }; + ArrayList list = new ArrayList<>(); + + initializeListFromArray(array, list); + printList("ArrayList vor Modifikationen:", list); + + addValues(list, 10, -5); + removeElementAt(list, 1); + printList("ArrayList nach Modifikationen:", list); + + sortList(list); + printList("ArrayList nach Sortierung:", list); + + shuffleList(list); + printList("ArrayList nach dem Mischen:", list); + + printMinMaxValues(list); + } + + // Initialisiert die ArrayList mit Werten aus dem Array + private static void initializeListFromArray(int[] array, ArrayList list) { + for (int num : array) { + list.add(num); + } + } + + // Fügt der ArrayList zwei Werte hinzu + private static void addValues(ArrayList list, int value1, int value2) { + list.add(value1); + list.add(value2); + } + + // Entfernt das Element an einer bestimmten Position + private static void removeElementAt(ArrayList list, int index) { + if (index >= 0 && index < list.size()) { + list.remove(index); + } + } + + // Gibt den Inhalt der ArrayList aus + private static void printList(String message, ArrayList list) { + System.out.println(message); + for (int num : list) { + System.out.print(num + " "); + } + System.out.println(); + } + + // Sortiert die ArrayList + private static void sortList(ArrayList list) { + Collections.sort(list); + } + + // Mischt die ArrayList + private static void shuffleList(ArrayList list) { + Collections.shuffle(list); + } + + // Gibt den maximalen und minimalen Wert der ArrayList aus + private static void printMinMaxValues(ArrayList list) { + int max = Collections.max(list); + int min = Collections.min(list); + System.out.println("Maximaler Wert: " + max); + System.out.println("Minimaler Wert: " + min); + } +} diff --git a/Code/Steiner/repetition-classes-oop/.vscode/settings.json b/Code/Steiner/repetition-classes-oop/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/Steiner/repetition-classes-oop/.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/repetition-classes-oop/README.md b/Code/Steiner/repetition-classes-oop/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/Steiner/repetition-classes-oop/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/repetition-classes-oop/bin/App.class b/Code/Steiner/repetition-classes-oop/bin/App.class new file mode 100644 index 0000000..2184291 Binary files /dev/null and b/Code/Steiner/repetition-classes-oop/bin/App.class differ diff --git a/Code/Steiner/repetition-classes-oop/bin/Teacher.class b/Code/Steiner/repetition-classes-oop/bin/Teacher.class new file mode 100644 index 0000000..8fb4a05 Binary files /dev/null and b/Code/Steiner/repetition-classes-oop/bin/Teacher.class differ diff --git a/Code/Steiner/repetition-classes-oop/src/App.class b/Code/Steiner/repetition-classes-oop/src/App.class new file mode 100644 index 0000000..15d66cb Binary files /dev/null and b/Code/Steiner/repetition-classes-oop/src/App.class differ diff --git a/Code/Steiner/repetition-classes-oop/src/App.java b/Code/Steiner/repetition-classes-oop/src/App.java new file mode 100644 index 0000000..98dc525 --- /dev/null +++ b/Code/Steiner/repetition-classes-oop/src/App.java @@ -0,0 +1,28 @@ + +// Main application class where we create a Teacher object and display some +// info. +public class App { + public static void main(String[] args) throws Exception { + // Sample data for creating a Teacher object. + String firstname = "Karl"; + String lastname = "Marx"; + int compensation = 1000000; + String[] subjects = { "Economics", "Math", "German" }; + + // Creating a Teacher object using the data above. + Teacher teacher = new Teacher(firstname, lastname, compensation, subjects); + + // Printing the teacher's full name. + System.out.println("Teacher: " + teacher.getFirstname() + " " + teacher.getLastname()); + + // Printing the teacher's compensation. + System.out.println("Compensation: " + teacher.getCompensation()); + + // Printing the subjects the teacher teaches. + System.out.print("Subjects: "); + // Loop through each subject in the array and print it. + for (String subject : teacher.getSubjects()) { + System.out.print(subject + " "); + } + } +} diff --git a/Code/Steiner/repetition-classes-oop/src/Teacher.class b/Code/Steiner/repetition-classes-oop/src/Teacher.class new file mode 100644 index 0000000..37c06ba Binary files /dev/null and b/Code/Steiner/repetition-classes-oop/src/Teacher.class differ diff --git a/Code/Steiner/repetition-classes-oop/src/Teacher.java b/Code/Steiner/repetition-classes-oop/src/Teacher.java new file mode 100644 index 0000000..4a0af07 --- /dev/null +++ b/Code/Steiner/repetition-classes-oop/src/Teacher.java @@ -0,0 +1,61 @@ +// The Teacher class represents a teacher with a first name, last name, compensation, and subjects they teach. +public class Teacher { + // Private fields to store the teacher's first name, last name, compensation, + // and subjects. + private String firstname; + private String lastname; + private int compensation; + private String[] subjects; + + // Constructor for initializing a Teacher object with provided details. + public Teacher(String firstname, String lastname, int compensation, String[] subjects) { + // Assigning the provided first name to the teacher's firstname field. + this.firstname = firstname; + // Assigning the provided last name to the teacher's lastname field. + this.lastname = lastname; + // Assigning the provided compensation to the teacher's compensation field. + this.compensation = compensation; + // Assigning the provided array of subjects to the teacher's subjects field. + this.subjects = subjects; + } + + // Getter method for getting the teacher's first name. + public String getFirstname() { + return firstname; + } + + // Setter method for setting a new first name for the teacher. + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + // Getter method for getting the teacher's last name. + public String getLastname() { + return lastname; + } + + // Setter method for setting a new last name for the teacher. + public void setLastname(String lastname) { + this.lastname = lastname; + } + + // Getter method for getting the teacher's compensation. + public int getCompensation() { + return compensation; + } + + // Setter method for setting a new compensation for the teacher. + public void setCompensation(int compensation) { + this.compensation = compensation; + } + + // Getter method for getting the array of subjects the teacher teaches. + public String[] getSubjects() { + return subjects; + } + + // Setter method for setting a new array of subjects for the teacher. + public void setSubjects(String[] subjects) { + this.subjects = subjects; + } +} \ No newline at end of file