diff --git a/Code/Steiner/battleShip/src/App.class b/Code/Steiner/battleShip/src/App.class index a7fc5b4..8ef7845 100644 Binary files a/Code/Steiner/battleShip/src/App.class and b/Code/Steiner/battleShip/src/App.class differ diff --git a/Code/Steiner/oopPruefung1/.vscode/settings.json b/Code/Steiner/oopPruefung1/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/Steiner/oopPruefung1/.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/oopPruefung1/README.md b/Code/Steiner/oopPruefung1/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/Steiner/oopPruefung1/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/oopPruefung1/bin/App.class b/Code/Steiner/oopPruefung1/bin/App.class new file mode 100644 index 0000000..5f8386c Binary files /dev/null and b/Code/Steiner/oopPruefung1/bin/App.class differ diff --git a/Code/Steiner/oopPruefung1/bin/Time.class b/Code/Steiner/oopPruefung1/bin/Time.class new file mode 100644 index 0000000..0047eb7 Binary files /dev/null and b/Code/Steiner/oopPruefung1/bin/Time.class differ diff --git a/Code/Steiner/oopPruefung1/src/App.class b/Code/Steiner/oopPruefung1/src/App.class new file mode 100644 index 0000000..4cc0957 Binary files /dev/null and b/Code/Steiner/oopPruefung1/src/App.class differ diff --git a/Code/Steiner/oopPruefung1/src/App.java b/Code/Steiner/oopPruefung1/src/App.java new file mode 100644 index 0000000..2a6785d --- /dev/null +++ b/Code/Steiner/oopPruefung1/src/App.java @@ -0,0 +1,16 @@ +// Luca Burger +// Aufgabe 12 + +public class App { + public static void main(String[] args) throws Exception { + Time myTime1 = new Time(5, 42); + Time myTime2 = new Time(3, 27); + Time myTime3 = new Time(5, 20); + Time myTime4 = new Time(3, 10); + Time myTime5 = new Time(3, 20); + + System.out.println(Time.subtract(myTime3, myTime4)); + System.out.println(Time.convertToMinute(myTime1)); + + } +} diff --git a/Code/Steiner/oopPruefung1/src/Time.class b/Code/Steiner/oopPruefung1/src/Time.class new file mode 100644 index 0000000..442f882 Binary files /dev/null and b/Code/Steiner/oopPruefung1/src/Time.class differ diff --git a/Code/Steiner/oopPruefung1/src/Time.java b/Code/Steiner/oopPruefung1/src/Time.java new file mode 100644 index 0000000..68994f4 --- /dev/null +++ b/Code/Steiner/oopPruefung1/src/Time.java @@ -0,0 +1,37 @@ +// Luca Burger +// Aufgabe 12 + +public class Time { + int hour; + int minute; + + Time(int hour, int minute) { + this.hour = hour; + this.minute = minute; + } + + void add(Time time, Time time2) { + time.hour += time2.hour; + time.minute += time2.minute; + } + + static int subtract(Time time, Time time2) { + int minute1 = convertToMinute(time); + int minute2 = convertToMinute(time2); + return minute1 - minute2; + + } + + static int convertToMinute(Time time) { + int add = time.hour * 60; + return time.minute += add; + } + + static String print(Time myTime) { + String text = ""; + text += myTime.hour; + text += ":"; + text += myTime.minute; + return text; + } +} diff --git a/Code/Steiner/oopUebung5/.vscode/settings.json b/Code/Steiner/oopUebung5/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/Steiner/oopUebung5/.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/oopUebung5/README.md b/Code/Steiner/oopUebung5/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/Steiner/oopUebung5/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/oopUebung5/bin/App.class b/Code/Steiner/oopUebung5/bin/App.class new file mode 100644 index 0000000..1081e8c Binary files /dev/null and b/Code/Steiner/oopUebung5/bin/App.class differ diff --git a/Code/Steiner/oopUebung5/bin/Position.class b/Code/Steiner/oopUebung5/bin/Position.class new file mode 100644 index 0000000..0e75ff2 Binary files /dev/null and b/Code/Steiner/oopUebung5/bin/Position.class differ diff --git a/Code/Steiner/oopUebung5/src/App.class b/Code/Steiner/oopUebung5/src/App.class new file mode 100644 index 0000000..e5cf113 Binary files /dev/null and b/Code/Steiner/oopUebung5/src/App.class differ diff --git a/Code/Steiner/oopUebung5/src/App.java b/Code/Steiner/oopUebung5/src/App.java new file mode 100644 index 0000000..bfae0f3 --- /dev/null +++ b/Code/Steiner/oopUebung5/src/App.java @@ -0,0 +1,63 @@ +import java.util.*; + +public class App { + public static void main(String[] args) throws Exception { + Position player = new Position(); + player.x = 0; + player.y = 0; + + while (true) { + player.printPosition(player); + int direction = whereToMove(player); + int distance = howFar(player); + switch (direction) { + case 1: + player.goUp(distance); + break; + case 2: + player.goRight(distance); + break; + case 3: + player.goDown(distance); + break; + case 4: + player.goLeft(distance); + break; + + default: + System.out.println("Was not a valid direction || distance"); + break; + } + } + } + + public static int whereToMove(Position player) { + Scanner scan = new Scanner(System.in); + int input; + while (true) { + System.out.println("Where do you want to move (1 up, 2 right, 3 down, 4 left)"); + try { + input = scan.nextInt(); + break; + } catch (Exception e) { + System.out.println("Input was not an int"); + } + } + return input; + } + + public static int howFar(Position player) { + Scanner scan = new Scanner(System.in); + int input; + while (true) { + System.out.println("How far?"); + try { + input = scan.nextInt(); + break; + } catch (Exception e) { + System.out.println("Input was not an int"); + } + } + return input; + } +} diff --git a/Code/Steiner/oopUebung5/src/Position.class b/Code/Steiner/oopUebung5/src/Position.class new file mode 100644 index 0000000..5a9045b Binary files /dev/null and b/Code/Steiner/oopUebung5/src/Position.class differ diff --git a/Code/Steiner/oopUebung5/src/Position.java b/Code/Steiner/oopUebung5/src/Position.java new file mode 100644 index 0000000..8e792ed --- /dev/null +++ b/Code/Steiner/oopUebung5/src/Position.java @@ -0,0 +1,24 @@ +public class Position { + int x; + int y; + + void goLeft(int howFar) { + x = x - howFar; + } + + void goRight(int howFar) { + x = x + howFar; + } + + void goUp(int howFar) { + y = y - howFar; + } + + void goDown(int howFar) { + y = y + howFar; + } + + void printPosition(Position player) { + System.out.println("Player Position: (" + player.x + "/" + player.y + ")"); + } +} diff --git a/Code/Steiner/oopUebung6/.vscode/settings.json b/Code/Steiner/oopUebung6/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/Steiner/oopUebung6/.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/oopUebung6/README.md b/Code/Steiner/oopUebung6/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/Steiner/oopUebung6/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/oopUebung6/bin/Rectangle.class b/Code/Steiner/oopUebung6/bin/Rectangle.class new file mode 100644 index 0000000..838cbdb Binary files /dev/null and b/Code/Steiner/oopUebung6/bin/Rectangle.class differ diff --git a/Code/Steiner/oopUebung6/bin/RectangleTest.class b/Code/Steiner/oopUebung6/bin/RectangleTest.class new file mode 100644 index 0000000..71fd2ab Binary files /dev/null and b/Code/Steiner/oopUebung6/bin/RectangleTest.class differ diff --git a/Code/Steiner/oopUebung6/src/Rectangle.class b/Code/Steiner/oopUebung6/src/Rectangle.class new file mode 100644 index 0000000..5ca753c Binary files /dev/null and b/Code/Steiner/oopUebung6/src/Rectangle.class differ diff --git a/Code/Steiner/oopUebung6/src/Rectangle.java b/Code/Steiner/oopUebung6/src/Rectangle.java new file mode 100644 index 0000000..e509120 --- /dev/null +++ b/Code/Steiner/oopUebung6/src/Rectangle.java @@ -0,0 +1,80 @@ +public class Rectangle { + // Private attributes for length and width + private double length; + private double width; + + // Constructor with two parameters to initialize the length and width + public Rectangle(double length, double width) { + this.length = length; + this.width = width; + } + + // Setter methods + public void setLength(double length) { + this.length = length; + } + + public void setWidth(double width) { + this.width = width; + } + + public void setSides(double length, double width) { + this.length = length; + this.width = width; + } + + // Getter methods + public double getLength() { + return length; + } + + public double getWidth() { + return width; + } + + // Method to get the longer side + public double getLongerSide() { + return Math.max(length, width); + } + + // Method to get the shorter side + public double getShorterSide() { + return Math.min(length, width); + } + + // Method to calculate the diagonal of the rectangle + public double getDiagonal() { + return Math.sqrt(length * length + width * width); + } + + // Method to calculate the area of the rectangle + public double getArea() { + return length * width; + } + + // Method to calculate the perimeter of the rectangle + public double getPerimeter() { + return 2 * (length + width); + } + + // Methods to adjust length and width + public void increaseLength(double l) { + length += l; + } + + public void increaseWidth(double w) { + width += w; + } + + public void decreaseLength(double l) { + length -= l; + if (length < 0) + length = 0; // Ensure length doesn't become negative + } + + public void decreaseWidth(double w) { + width -= w; + if (width < 0) + width = 0; // Ensure width doesn't become negative + } +} diff --git a/Code/Steiner/oopUebung6/src/RectangleTest.class b/Code/Steiner/oopUebung6/src/RectangleTest.class new file mode 100644 index 0000000..ac61761 Binary files /dev/null and b/Code/Steiner/oopUebung6/src/RectangleTest.class differ diff --git a/Code/Steiner/oopUebung6/src/RectangleTest.java b/Code/Steiner/oopUebung6/src/RectangleTest.java new file mode 100644 index 0000000..41d9186 --- /dev/null +++ b/Code/Steiner/oopUebung6/src/RectangleTest.java @@ -0,0 +1,67 @@ +import java.util.Scanner; + +public class RectangleTest { + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + + // Get user input for length and width + System.out.print("Enter the length of the rectangle: "); + double length = scanner.nextDouble(); + + System.out.print("Enter the width of the rectangle: "); + double width = scanner.nextDouble(); + + // Create a Rectangle object + Rectangle rectangle = new Rectangle(length, width); + + System.out.println("What do you want to do? (1: increase, 2: decrease)"); + int input = scanner.nextInt(); + + if (input == 1) { + // Increase the dimension + System.out.println("Which dimension do you want to increase? (1: width, 2: length)"); + input = scanner.nextInt(); + if (input == 1) { + // Increase width + System.out.print("Increase width by: "); + double increaseBy = scanner.nextDouble(); + rectangle.increaseWidth(increaseBy); + } else if (input == 2) { + // Increase length + System.out.print("Increase length by: "); + double increaseBy = scanner.nextDouble(); + rectangle.increaseLength(increaseBy); + } else { + System.out.println("Invalid input for dimension choice."); + } + } else if (input == 2) { + // Decrease the dimension + System.out.println("Which dimension do you want to decrease? (1: width, 2: length)"); + input = scanner.nextInt(); + if (input == 1) { + // Decrease width + System.out.print("Decrease width by: "); + double decreaseBy = scanner.nextDouble(); + rectangle.decreaseWidth(decreaseBy); + } else if (input == 2) { + // Decrease length + System.out.print("Decrease length by: "); + double decreaseBy = scanner.nextDouble(); + rectangle.decreaseLength(decreaseBy); + } else { + System.out.println("Invalid input for dimension choice."); + } + } else { + System.out.println("Invalid input for action choice."); + } + + // Display the results + System.out.println("Longer side: " + rectangle.getLongerSide()); + System.out.println("Shorter side: " + rectangle.getShorterSide()); + System.out.println("Diagonal: " + rectangle.getDiagonal()); + System.out.println("Area: " + rectangle.getArea()); + System.out.println("Perimeter: " + rectangle.getPerimeter()); + + scanner.close(); + } +} diff --git a/Code/Steiner/oopUebung7/.vscode/settings.json b/Code/Steiner/oopUebung7/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/Steiner/oopUebung7/.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/oopUebung7/README.md b/Code/Steiner/oopUebung7/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/Steiner/oopUebung7/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/oopUebung7/bin/App.class b/Code/Steiner/oopUebung7/bin/App.class new file mode 100644 index 0000000..c627b68 Binary files /dev/null and b/Code/Steiner/oopUebung7/bin/App.class differ diff --git a/Code/Steiner/oopUebung7/bin/Person.class b/Code/Steiner/oopUebung7/bin/Person.class new file mode 100644 index 0000000..59306e8 Binary files /dev/null and b/Code/Steiner/oopUebung7/bin/Person.class differ diff --git a/Code/Steiner/oopUebung7/src/App.class b/Code/Steiner/oopUebung7/src/App.class new file mode 100644 index 0000000..d6b1b39 Binary files /dev/null and b/Code/Steiner/oopUebung7/src/App.class differ diff --git a/Code/Steiner/oopUebung7/src/App.java b/Code/Steiner/oopUebung7/src/App.java new file mode 100644 index 0000000..d4c9d4d --- /dev/null +++ b/Code/Steiner/oopUebung7/src/App.java @@ -0,0 +1,9 @@ +public class App { + public static void main(String[] args) throws Exception { + Person myPerson1 = new Person("Hans", 200); + myPerson1.validTransaction(500); + System.out.println(myPerson1.getBalance()); + myPerson1.setName("Luca"); + System.out.println(myPerson1.getName()); + } +} \ No newline at end of file diff --git a/Code/Steiner/oopUebung7/src/Person.class b/Code/Steiner/oopUebung7/src/Person.class new file mode 100644 index 0000000..6defc12 Binary files /dev/null and b/Code/Steiner/oopUebung7/src/Person.class differ diff --git a/Code/Steiner/oopUebung7/src/Person.java b/Code/Steiner/oopUebung7/src/Person.java new file mode 100644 index 0000000..4f4ab14 --- /dev/null +++ b/Code/Steiner/oopUebung7/src/Person.java @@ -0,0 +1,29 @@ +public class Person { + private String name; + private double balance; + + Person(String person, double money) { + name = person; + balance = money; + } + + boolean validTransaction(double money) { + if (balance + money >= 0) { + balance += money; + return true; + } else + return false; + } + + void setName(String name) { + this.name = name; + } + + String getName() { + return name; + } + + double getBalance() { + return balance; + } +} \ No newline at end of file diff --git a/Code/Steiner/oopUebung8/.vscode/settings.json b/Code/Steiner/oopUebung8/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/Steiner/oopUebung8/.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/oopUebung8/README.md b/Code/Steiner/oopUebung8/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/Steiner/oopUebung8/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/oopUebung8/bin/App.class b/Code/Steiner/oopUebung8/bin/App.class new file mode 100644 index 0000000..fe4e1b6 Binary files /dev/null and b/Code/Steiner/oopUebung8/bin/App.class differ diff --git a/Code/Steiner/oopUebung8/bin/Gehege.class b/Code/Steiner/oopUebung8/bin/Gehege.class new file mode 100644 index 0000000..69a532f Binary files /dev/null and b/Code/Steiner/oopUebung8/bin/Gehege.class differ diff --git a/Code/Steiner/oopUebung8/bin/Tier.class b/Code/Steiner/oopUebung8/bin/Tier.class new file mode 100644 index 0000000..3995d76 Binary files /dev/null and b/Code/Steiner/oopUebung8/bin/Tier.class differ diff --git a/Code/Steiner/oopUebung8/src/App.class b/Code/Steiner/oopUebung8/src/App.class new file mode 100644 index 0000000..f07de5f Binary files /dev/null and b/Code/Steiner/oopUebung8/src/App.class differ diff --git a/Code/Steiner/oopUebung8/src/App.java b/Code/Steiner/oopUebung8/src/App.java new file mode 100644 index 0000000..a149d9b --- /dev/null +++ b/Code/Steiner/oopUebung8/src/App.java @@ -0,0 +1,29 @@ +public class App { + public static void main(String[] args) { + // Einige Tiere erstellen + Tier loewe = new Tier("Löwe", "Leo"); + Tier elefant = new Tier("Elefant", "Dumbo"); + Tier pinguin = new Tier("Pinguin", "Pingu"); + + // Gehege mit Kapazität von 5 Tieren erstellen + Gehege gehege1 = new Gehege(1, 5); + + // Tiere zum Gehege hinzufügen + gehege1.hinzufuegenTier(loewe); + gehege1.hinzufuegenTier(elefant); + gehege1.hinzufuegenTier(pinguin); + + // Informationen ausgeben + System.out.println("Gehege Nummer: " + gehege1.getNummer()); + Tier[] tiereImGehege = gehege1.getTiere(); + for (Tier tier : tiereImGehege) { + System.out.println("Tier: " + tier.getArt() + " - Name: " + tier.getName()); + } + + // Name eines Tieres ändern + loewe.setName("Simba"); + + // Überprüfen, ob der Name des Tieres aktualisiert wurde + System.out.println("Aktualisierter Name des Löwen: " + loewe.getName()); + } +} diff --git a/Code/Steiner/oopUebung8/src/Gehege.class b/Code/Steiner/oopUebung8/src/Gehege.class new file mode 100644 index 0000000..6185e5e Binary files /dev/null and b/Code/Steiner/oopUebung8/src/Gehege.class differ diff --git a/Code/Steiner/oopUebung8/src/Gehege.java b/Code/Steiner/oopUebung8/src/Gehege.java new file mode 100644 index 0000000..95ab7b6 --- /dev/null +++ b/Code/Steiner/oopUebung8/src/Gehege.java @@ -0,0 +1,54 @@ +public class Gehege { + private int nummer; + private Tier[] tierListe; + private int aktuelleAnzahlTiere; + private int kapazitaet; + + // Konstruktor, der die Nummer und die Kapazität des Geheges annimmt + Gehege(int nummer, int kapazitaet) { + this.nummer = nummer; + this.kapazitaet = kapazitaet; + this.tierListe = new Tier[kapazitaet]; + this.aktuelleAnzahlTiere = 0; + } + + // Methode zum Hinzufügen eines Tieres + public void hinzufuegenTier(Tier tier) { + if (aktuelleAnzahlTiere < kapazitaet) { + tierListe[aktuelleAnzahlTiere] = tier; + aktuelleAnzahlTiere++; + System.out.println("Tier hinzugefügt: " + tier.getName()); + } else { + System.out.println("Das Gehege ist voll. Tier konnte nicht hinzugefügt werden."); + } + } + + // Methode zum Entfernen eines Tieres + public void entfernenTier(Tier tier) { + for (int i = 0; i < aktuelleAnzahlTiere; i++) { + if (tierListe[i].equals(tier)) { + // Tier entfernen und Array neu ordnen + for (int j = i; j < aktuelleAnzahlTiere - 1; j++) { + tierListe[j] = tierListe[j + 1]; + } + tierListe[aktuelleAnzahlTiere - 1] = null; + aktuelleAnzahlTiere--; + System.out.println("Tier entfernt: " + tier.getName()); + return; + } + } + System.out.println("Tier nicht gefunden: " + tier.getName()); + } + + // Methode zum Zurückgeben der aktuellen Liste der Tiere + public Tier[] getTiere() { + Tier[] tiereImGehege = new Tier[aktuelleAnzahlTiere]; + System.arraycopy(tierListe, 0, tiereImGehege, 0, aktuelleAnzahlTiere); + return tiereImGehege; + } + + // Methode zum Zurückgeben der Nummer des Geheges + public int getNummer() { + return nummer; + } +} diff --git a/Code/Steiner/oopUebung8/src/Tier.class b/Code/Steiner/oopUebung8/src/Tier.class new file mode 100644 index 0000000..355e21a Binary files /dev/null and b/Code/Steiner/oopUebung8/src/Tier.class differ diff --git a/Code/Steiner/oopUebung8/src/Tier.java b/Code/Steiner/oopUebung8/src/Tier.java new file mode 100644 index 0000000..cd1fc99 --- /dev/null +++ b/Code/Steiner/oopUebung8/src/Tier.java @@ -0,0 +1,25 @@ +public class Tier { + private String art; + private String name; + + // Konstruktor zur Setzung von Art und Name + public Tier(String art, String name) { + this.art = art; + this.name = name; + } + + // Getter für Art + public String getArt() { + return art; + } + + // Getter für Name + public String getName() { + return name; + } + + // Setter für Name + public void setName(String name) { + this.name = name; + } +} diff --git a/Code/Steiner/oop_theorie_2/.vscode/settings.json b/Code/Steiner/oop_theorie_2/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/Steiner/oop_theorie_2/.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/oop_theorie_2/README.md b/Code/Steiner/oop_theorie_2/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/Steiner/oop_theorie_2/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/oop_theorie_2/bin/App.class b/Code/Steiner/oop_theorie_2/bin/App.class new file mode 100644 index 0000000..2d46d91 Binary files /dev/null and b/Code/Steiner/oop_theorie_2/bin/App.class differ diff --git a/Code/Steiner/oop_theorie_2/bin/Person.class b/Code/Steiner/oop_theorie_2/bin/Person.class new file mode 100644 index 0000000..010d006 Binary files /dev/null and b/Code/Steiner/oop_theorie_2/bin/Person.class differ diff --git a/Code/Steiner/oop_theorie_2/src/App.class b/Code/Steiner/oop_theorie_2/src/App.class new file mode 100644 index 0000000..281644f Binary files /dev/null and b/Code/Steiner/oop_theorie_2/src/App.class differ diff --git a/Code/Steiner/oop_theorie_2/src/App.java b/Code/Steiner/oop_theorie_2/src/App.java new file mode 100644 index 0000000..2241763 --- /dev/null +++ b/Code/Steiner/oop_theorie_2/src/App.java @@ -0,0 +1,25 @@ +public class App { + public static void main(String[] args) throws Exception { + // Create an array of Person objects + Person[] persons = new Person[5]; + + // Initialize the Person objects + persons[0] = new Person("Hans", 2012); + persons[1] = new Person("Peter", 2011); + persons[2] = new Person("Jochen", 2013); + persons[3] = new Person("Christian", 2050); + persons[4] = new Person("Tobias", 1932); + + // Print each person + for (Person person : persons) { + person.printPerson(); + } + + int sumAge = 0; + for (Person person : persons) { + sumAge += person.getAge(); + } + + System.out.println("The sum of the age of all people is: " + sumAge); + } +} diff --git a/Code/Steiner/oop_theorie_2/src/Person.class b/Code/Steiner/oop_theorie_2/src/Person.class new file mode 100644 index 0000000..c850055 Binary files /dev/null and b/Code/Steiner/oop_theorie_2/src/Person.class differ diff --git a/Code/Steiner/oop_theorie_2/src/Person.java b/Code/Steiner/oop_theorie_2/src/Person.java new file mode 100644 index 0000000..0c1facf --- /dev/null +++ b/Code/Steiner/oop_theorie_2/src/Person.java @@ -0,0 +1,36 @@ +import java.time.LocalDate; + +class Person { + private String name; + private int age; + + Person(String name, int yearOfBirth) { + this.name = name; + LocalDate currentDate = LocalDate.now(); + int year = currentDate.getYear(); + this.age = year - yearOfBirth; + if (this.age < 0) { + this.age = 0; + } + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public void printPerson() { + System.out.println(name + " " + age); + } +} diff --git a/Code/Steiner/oppUebung4/bin/App.class b/Code/Steiner/oppUebung4/bin/App.class index 9f2b697..528f790 100644 Binary files a/Code/Steiner/oppUebung4/bin/App.class and b/Code/Steiner/oppUebung4/bin/App.class differ diff --git a/Code/Steiner/oppUebung4/bin/Article.class b/Code/Steiner/oppUebung4/bin/Article.class new file mode 100644 index 0000000..41549fa Binary files /dev/null and b/Code/Steiner/oppUebung4/bin/Article.class differ diff --git a/Code/Steiner/oppUebung4/bin/Storage.class b/Code/Steiner/oppUebung4/bin/Storage.class index 73e7c72..102353f 100644 Binary files a/Code/Steiner/oppUebung4/bin/Storage.class and b/Code/Steiner/oppUebung4/bin/Storage.class differ diff --git a/Code/Steiner/oppUebung4/bin/Unit.class b/Code/Steiner/oppUebung4/bin/Unit.class deleted file mode 100644 index d519a7d..0000000 Binary files a/Code/Steiner/oppUebung4/bin/Unit.class and /dev/null differ diff --git a/Code/Steiner/oppUebung4/src/App.java b/Code/Steiner/oppUebung4/src/App.java index 8c2a09e..9f1da0c 100644 --- a/Code/Steiner/oppUebung4/src/App.java +++ b/Code/Steiner/oppUebung4/src/App.java @@ -1,5 +1,7 @@ +import java.util.*; + public class App { - public static void main(String[] args) throws Exception { + public static void main(String[] args) { Object[][] article = { { 1, "Banana", 5, "Stk" }, { 23, "Flour", 2, "KG" }, @@ -13,39 +15,81 @@ public class App { { 56, "Bread", 2, "Loaves" }, { 90, "Cheese", 1, "KG" }, { 32, "Tomato", 8, "Stk" }, - { 11, "Salt", 1, "KG" } - + { 11, "Salt", 1, "KG" }, + { 13, "Cocaine", 12, "mg" } }; // Create an array to hold Storage objects - Storage[] myStorage = new Storage[article.length]; + Storage[] myStorage = new Storage[1000]; + Storage[] myArticles = new Storage[article.length]; - // Create and store Storage objects in the array + // Initialize 1000 possible storage places + for (int i = 0; i < myStorage.length; i++) { + myStorage[i] = initializStorage(); // Initialize storage with default values + } + + // Create and store Storage objects in the myArticles array for (int i = 0; i < article.length; i++) { - myStorage[i] = createStorage(article[i]); + myArticles[i] = createStorage(article[i]); + } + + // Fill some of the myStorage array with the contents of myArticles + // For example, place the first few articles into the first few storage slots + for (int i = 0; i < myArticles.length; i++) { + if (i < myStorage.length) { + myStorage[i] = myArticles[i]; + } } // Print out the details of each Item for (Storage storage : myStorage) { printItems(storage); } + String search = "Banana"; + Storage foundItems = lookUp(myStorage, search); + if (foundItems != null) { + System.out.println("-------------------"); + System.out.println("You searched for " + search); + printItems(foundItems); + } else { + System.out.println("No " + search + " found"); + } + } + private static Storage initializStorage() { + Storage storage = new Storage(); + storage.storageId = 0; + storage.article.name = ""; + storage.quantaty = 0; + storage.article.unit = ""; + return storage; } private static Storage createStorage(Object[] article) { Storage storage = new Storage(); storage.storageId = (int) article[0]; - storage.name = (String) article[1]; - storage.unit.quantaty = (int) article[2]; - storage.unit.unit = (String) article[3]; + storage.article.name = (String) article[1]; + storage.quantaty = (int) article[2]; + storage.article.unit = (String) article[3]; return storage; } private static void printItems(Storage storage) { - System.out.println("Item on shelf: " + storage.storageId); - System.out.println("Item name: " + storage.name); - System.out.println("Item(s) on stock: " + storage.unit.quantaty); - System.out.println("Measured unit: " + storage.unit.unit); - System.out.println("-----------------------------------------"); + if (storage.storageId != 0) { // Only print if there's an actual item + System.out.println("Item on shelf: " + storage.storageId); + System.out.println("Item name: " + storage.article.name); + System.out.println("Item(s) on stock: " + storage.quantaty); + System.out.println("Measured unit: " + storage.article.unit); + System.out.println("-----------------------------------------"); + } + } + + private static Storage lookUp(Storage[] myStorage, String name) { + for (Storage storage : myStorage) { + if (storage.article.name == name) { + return storage; + } + } + return null; } } diff --git a/Code/Steiner/oppUebung4/src/Article.java b/Code/Steiner/oppUebung4/src/Article.java new file mode 100644 index 0000000..609bb4e --- /dev/null +++ b/Code/Steiner/oppUebung4/src/Article.java @@ -0,0 +1,4 @@ +class Article { + String unit; + String name; +} diff --git a/Code/Steiner/oppUebung4/src/Storage.java b/Code/Steiner/oppUebung4/src/Storage.java index baf67fa..3a58af5 100644 --- a/Code/Steiner/oppUebung4/src/Storage.java +++ b/Code/Steiner/oppUebung4/src/Storage.java @@ -1,5 +1,6 @@ -public class Storage { + +class Storage { int storageId; - String name; - Unit unit = new Unit(); + Article article = new Article(); + int quantaty; } diff --git a/Code/Steiner/oppUebung4/src/Unit.java b/Code/Steiner/oppUebung4/src/Unit.java deleted file mode 100644 index 21f91e8..0000000 --- a/Code/Steiner/oppUebung4/src/Unit.java +++ /dev/null @@ -1,4 +0,0 @@ -public class Unit { - int quantaty; - String unit; -} diff --git a/Code/Steiner/test27.8.24/.vscode/settings.json b/Code/Steiner/test27.8.24/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/Steiner/test27.8.24/.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/test27.8.24/README.md b/Code/Steiner/test27.8.24/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/Steiner/test27.8.24/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/test27.8.24/bin/App.class b/Code/Steiner/test27.8.24/bin/App.class new file mode 100644 index 0000000..e637540 Binary files /dev/null and b/Code/Steiner/test27.8.24/bin/App.class differ diff --git a/Code/Steiner/test27.8.24/src/App.class b/Code/Steiner/test27.8.24/src/App.class new file mode 100644 index 0000000..ea59367 Binary files /dev/null and b/Code/Steiner/test27.8.24/src/App.class differ diff --git a/Code/Steiner/test27.8.24/src/App.java b/Code/Steiner/test27.8.24/src/App.java new file mode 100644 index 0000000..fb50bd1 --- /dev/null +++ b/Code/Steiner/test27.8.24/src/App.java @@ -0,0 +1,23 @@ +import java.util.Arrays; + +public class App { + public static void main(String[] args) throws Exception { + int[] strength = new int[5]; + + strength[0] = 5; + strength[1] = 12; + strength[2] = 18; + strength[3] = 2; + strength[4] = 1; + + for (int i = 0; i < strength.length; i++) { + System.out.println(strength[i]); + } + System.out.println("-------------------------------------"); + Arrays.sort(strength); + + for (int i = 0; i < strength.length; i++) { + System.out.println(strength[i]); + } + } +} diff --git a/Code/ost/_00_hello_world/src/main/java/com/example/App.java b/Code/ost/_00_hello_world/src/main/java/com/example/App.java index aea1f3a..d2930cc 100644 --- a/Code/ost/_00_hello_world/src/main/java/com/example/App.java +++ b/Code/ost/_00_hello_world/src/main/java/com/example/App.java @@ -12,12 +12,13 @@ import javafx.stage.Stage; public class App extends Application { @Override + public void start(Stage stage) { var javaVersion = SystemInfo.javaVersion(); var javafxVersion = SystemInfo.javafxVersion(); - var label = new Label("Hello World"); - var scene = new Scene(new StackPane(label), 100, 100); + var label = new Label("Hello, World"); + var scene = new Scene(new StackPane(label), 640, 480); stage.setScene(scene); stage.show(); } diff --git a/Code/ost/_00_hello_world/target/classes/com/example/App.class b/Code/ost/_00_hello_world/target/classes/com/example/App.class index afbdcb5..247092f 100644 Binary files a/Code/ost/_00_hello_world/target/classes/com/example/App.class and b/Code/ost/_00_hello_world/target/classes/com/example/App.class differ diff --git a/Code/ost/_00_hello_world/target/classes/com/example/SystemInfo.class b/Code/ost/_00_hello_world/target/classes/com/example/SystemInfo.class index ae53960..487f8e1 100644 Binary files a/Code/ost/_00_hello_world/target/classes/com/example/SystemInfo.class and b/Code/ost/_00_hello_world/target/classes/com/example/SystemInfo.class differ diff --git a/Code/ost/_00_hello_world/target/classes/module-info.class b/Code/ost/_00_hello_world/target/classes/module-info.class index fb805fd..5e9b472 100644 Binary files a/Code/ost/_00_hello_world/target/classes/module-info.class and b/Code/ost/_00_hello_world/target/classes/module-info.class differ diff --git a/Code/ost/_00_hello_world/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/Code/ost/_00_hello_world/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst index e69de29..c4d055a 100644 --- a/Code/ost/_00_hello_world/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ b/Code/ost/_00_hello_world/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,3 @@ +module-info.class +com\example\App.class +com\example\SystemInfo.class