diff --git a/Code/Steiner/Zootest/.vscode/settings.json b/Code/Steiner/Zootest/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/Steiner/Zootest/.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/Zootest/README.md b/Code/Steiner/Zootest/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/Steiner/Zootest/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/Zootest/bin/Animal.class b/Code/Steiner/Zootest/bin/Animal.class new file mode 100644 index 0000000..13fa31a Binary files /dev/null and b/Code/Steiner/Zootest/bin/Animal.class differ diff --git a/Code/Steiner/Zootest/bin/Camel.class b/Code/Steiner/Zootest/bin/Camel.class new file mode 100644 index 0000000..53af884 Binary files /dev/null and b/Code/Steiner/Zootest/bin/Camel.class differ diff --git a/Code/Steiner/Zootest/bin/Climbing.class b/Code/Steiner/Zootest/bin/Climbing.class new file mode 100644 index 0000000..6c59e2b Binary files /dev/null and b/Code/Steiner/Zootest/bin/Climbing.class differ diff --git a/Code/Steiner/Zootest/bin/Eagle.class b/Code/Steiner/Zootest/bin/Eagle.class new file mode 100644 index 0000000..863ef92 Binary files /dev/null and b/Code/Steiner/Zootest/bin/Eagle.class differ diff --git a/Code/Steiner/Zootest/bin/Flying.class b/Code/Steiner/Zootest/bin/Flying.class new file mode 100644 index 0000000..67f3837 Binary files /dev/null and b/Code/Steiner/Zootest/bin/Flying.class differ diff --git a/Code/Steiner/Zootest/bin/Frog.class b/Code/Steiner/Zootest/bin/Frog.class new file mode 100644 index 0000000..d06e13b Binary files /dev/null and b/Code/Steiner/Zootest/bin/Frog.class differ diff --git a/Code/Steiner/Zootest/bin/Swimming.class b/Code/Steiner/Zootest/bin/Swimming.class new file mode 100644 index 0000000..19ec7c2 Binary files /dev/null and b/Code/Steiner/Zootest/bin/Swimming.class differ diff --git a/Code/Steiner/Zootest/bin/ZooTest.class b/Code/Steiner/Zootest/bin/ZooTest.class new file mode 100644 index 0000000..a3dead6 Binary files /dev/null and b/Code/Steiner/Zootest/bin/ZooTest.class differ diff --git a/Code/Steiner/Zootest/src/Animal.java b/Code/Steiner/Zootest/src/Animal.java new file mode 100644 index 0000000..186a13f --- /dev/null +++ b/Code/Steiner/Zootest/src/Animal.java @@ -0,0 +1,3 @@ +public abstract class Animal { + public abstract void makeSound(); +} diff --git a/Code/Steiner/Zootest/src/Camel.java b/Code/Steiner/Zootest/src/Camel.java new file mode 100644 index 0000000..3aab531 --- /dev/null +++ b/Code/Steiner/Zootest/src/Camel.java @@ -0,0 +1,11 @@ +public class Camel extends Animal implements Climbing { + @Override + public void makeSound() { + System.out.println("Desert Camel grumbles!"); + } + + @Override + public void climb() { + System.out.println("Desert Camel climbs a dune."); + } +} diff --git a/Code/Steiner/Zootest/src/Climbing.java b/Code/Steiner/Zootest/src/Climbing.java new file mode 100644 index 0000000..dda71ed --- /dev/null +++ b/Code/Steiner/Zootest/src/Climbing.java @@ -0,0 +1,3 @@ +public interface Climbing { + void climb(); +} diff --git a/Code/Steiner/Zootest/src/Eagle.java b/Code/Steiner/Zootest/src/Eagle.java new file mode 100644 index 0000000..3bb72c6 --- /dev/null +++ b/Code/Steiner/Zootest/src/Eagle.java @@ -0,0 +1,16 @@ +public class Eagle extends Animal implements Flying, Swimming { + @Override + public void makeSound() { + System.out.println("Eagle screams!"); + } + + @Override + public void fly() { + System.out.println("Eagle flies high in the sky."); + } + + @Override + public void swim() { + System.out.println("Eagle fishes in the water (swims...)."); + } +} diff --git a/Code/Steiner/Zootest/src/Flying.java b/Code/Steiner/Zootest/src/Flying.java new file mode 100644 index 0000000..6207c18 --- /dev/null +++ b/Code/Steiner/Zootest/src/Flying.java @@ -0,0 +1,4 @@ +public interface Flying { + void fly(); +} + diff --git a/Code/Steiner/Zootest/src/Frog.java b/Code/Steiner/Zootest/src/Frog.java new file mode 100644 index 0000000..c0768cc --- /dev/null +++ b/Code/Steiner/Zootest/src/Frog.java @@ -0,0 +1,16 @@ +public class Frog extends Animal implements Swimming, Climbing { + @Override + public void makeSound() { + System.out.println("Green Frog croaks!"); + } + + @Override + public void swim() { + System.out.println("Green Frog swims in the pond."); + } + + @Override + public void climb() { + System.out.println("Green Frog climbs a tree."); + } +} diff --git a/Code/Steiner/Zootest/src/Swimming.java b/Code/Steiner/Zootest/src/Swimming.java new file mode 100644 index 0000000..8df57a6 --- /dev/null +++ b/Code/Steiner/Zootest/src/Swimming.java @@ -0,0 +1,3 @@ +public interface Swimming { + void swim(); +} diff --git a/Code/Steiner/Zootest/src/ZooTest.java b/Code/Steiner/Zootest/src/ZooTest.java new file mode 100644 index 0000000..f0d3c01 --- /dev/null +++ b/Code/Steiner/Zootest/src/ZooTest.java @@ -0,0 +1,17 @@ +public class ZooTest { + public static void main(String[] args) { + Animal eagle = new Eagle(); + eagle.makeSound(); + ((Eagle) eagle).fly(); + ((Eagle) eagle).swim(); + + Animal frog = new Frog(); + frog.makeSound(); + ((Frog) frog).swim(); + ((Frog) frog).climb(); + + Animal camel = new Camel(); + camel.makeSound(); + ((Camel) camel).climb(); + } +} diff --git a/Code/Steiner/finallyTryCatchAndFinally/.vscode/settings.json b/Code/Steiner/finallyTryCatchAndFinally/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/Steiner/finallyTryCatchAndFinally/.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/finallyTryCatchAndFinally/README.md b/Code/Steiner/finallyTryCatchAndFinally/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/Steiner/finallyTryCatchAndFinally/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/finallyTryCatchAndFinally/bin/App.class b/Code/Steiner/finallyTryCatchAndFinally/bin/App.class new file mode 100644 index 0000000..4722d62 Binary files /dev/null and b/Code/Steiner/finallyTryCatchAndFinally/bin/App.class differ diff --git a/Code/Steiner/finallyTryCatchAndFinally/src/App.java b/Code/Steiner/finallyTryCatchAndFinally/src/App.java new file mode 100644 index 0000000..105870c --- /dev/null +++ b/Code/Steiner/finallyTryCatchAndFinally/src/App.java @@ -0,0 +1,32 @@ +public class App { + public static void main(String[] args) throws Exception { + String text = null; + int zahler = 24; + int nenner = 0; + + try { + System.out.println(text.length()); + System.out.println(zahler / nenner); + } catch (ArithmeticException e1) { + System.out.println("fehler: " + e1.getMessage()); + } catch (Exception e) { + System.out.println("fehler: " + e.getMessage()); + } finally { + System.out.println("ABORT"); + Thread.sleep(1000); + clear(); + } + } + + public static void clear() { + try { + if (System.getProperty("os.name").contains("Windows")) { + new ProcessBuilder("cmd", "/c", "cls").inheritIO().start().waitFor(); + } else { + new ProcessBuilder("clear").inheritIO().start().waitFor(); + } + } catch (Exception e) { + e.getMessage(); + } + } +} diff --git a/Code/Steiner/fractionsSteinerTask/.vscode/settings.json b/Code/Steiner/fractionsSteinerTask/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/Steiner/fractionsSteinerTask/.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/fractionsSteinerTask/README.md b/Code/Steiner/fractionsSteinerTask/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/Steiner/fractionsSteinerTask/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/fractionsSteinerTask/bin/Anteil.class b/Code/Steiner/fractionsSteinerTask/bin/Anteil.class new file mode 100644 index 0000000..727851e Binary files /dev/null and b/Code/Steiner/fractionsSteinerTask/bin/Anteil.class differ diff --git a/Code/Steiner/fractionsSteinerTask/bin/AnteilTest.class b/Code/Steiner/fractionsSteinerTask/bin/AnteilTest.class new file mode 100644 index 0000000..2e582a2 Binary files /dev/null and b/Code/Steiner/fractionsSteinerTask/bin/AnteilTest.class differ diff --git a/Code/Steiner/fractionsSteinerTask/bin/Bruch.class b/Code/Steiner/fractionsSteinerTask/bin/Bruch.class new file mode 100644 index 0000000..315d4a6 Binary files /dev/null and b/Code/Steiner/fractionsSteinerTask/bin/Bruch.class differ diff --git a/Code/Steiner/fractionsSteinerTask/bin/BruchTest.class b/Code/Steiner/fractionsSteinerTask/bin/BruchTest.class new file mode 100644 index 0000000..bba1747 Binary files /dev/null and b/Code/Steiner/fractionsSteinerTask/bin/BruchTest.class differ diff --git a/Code/Steiner/fractionsSteinerTask/src/Anteil.java b/Code/Steiner/fractionsSteinerTask/src/Anteil.java new file mode 100644 index 0000000..e92dd14 --- /dev/null +++ b/Code/Steiner/fractionsSteinerTask/src/Anteil.java @@ -0,0 +1,34 @@ +public class Anteil extends Bruch { + + private static Bruch verteilt = new Bruch(0, 1); + + // Standardkonstruktor: Anteil = 0 + public Anteil() { + super(0, 1); + } + + // Konstruktor mit Zähler und Nenner + public Anteil(int z, int n) { + super(z, n); + Bruch neuerAnteil = new Bruch(z, n); + verteilt = verteilt.addiere(neuerAnteil); + + if (verteilt.dezimalwert() > 1) { + System.out.println("Fehler: Der Gesamtwert der verteilten Anteile übersteigt 1."); + verteilt = verteilt.subtrahiere(neuerAnteil); // Rollback des Fehlers + setZaehler(0); // Setzt Anteil zurück + setNenner(1); + } + } + + // Methode, um den verteilten Anteil als double zu erhalten + public static double getVerteilt() { + return verteilt.dezimalwert(); + } + + // Methode, um den verbleibenden Anteil als Bruch zu erhalten + public static Bruch getRest() { + Bruch eins = new Bruch(1, 1); + return eins.subtrahiere(verteilt); + } +} diff --git a/Code/Steiner/fractionsSteinerTask/src/AnteilTest.java b/Code/Steiner/fractionsSteinerTask/src/AnteilTest.java new file mode 100644 index 0000000..456c9e2 --- /dev/null +++ b/Code/Steiner/fractionsSteinerTask/src/AnteilTest.java @@ -0,0 +1,57 @@ +public class AnteilTest { + public static void main(String[] args) { + + // Bruch-Test + + System.out.println("*** Aufgabe Bruch ergänzen"); + + Bruch bruch1 = new Bruch(1, 2); + + Bruch bruch2 = new Bruch(3, 4); + + Bruch bruch3 = bruch1.addiere(bruch2); + + bruch3.gekuerztausgeben(); + + System.out.println(""); + + System.out.println(bruch3.dezimalwert()); + + Bruch bruch4 = bruch1.subtrahiere(bruch2); + + bruch4.gekuerztausgeben(); + + System.out.println(""); + + System.out.println(bruch4.dezimalwert()); + + // Anteil-Test + + System.out.println(""); + + System.out.println("*** Aufgabe Anteil"); + + int vermoegen = 200000; + + Anteil anteil1 = new Anteil(1, 4); + + Anteil anteil2 = new Anteil(1, 2); + + System.out.println("Anteil anteil1: " + anteil1.bruchToString()); + + System.out.println("Betrag von anteil1: " + vermoegen * anteil1.dezimalwert()); + + System.out.println("Anteil anteil2: " + anteil2.bruchToString()); + + System.out.println("Betrag von anteil2: " + vermoegen * anteil2.dezimalwert()); + + System.out.println(""); + + // System.out.println("Verteilt: " + Anteil.verteilt.bruchToString()); + + System.out.println("Rest: " + anteil1.getRest().bruchToString()); + + System.out.println("Restbetrag: " + vermoegen * anteil1.getRest().dezimalwert()); + + } +} diff --git a/Code/Steiner/fractionsSteinerTask/src/Bruch.java b/Code/Steiner/fractionsSteinerTask/src/Bruch.java new file mode 100644 index 0000000..5900b87 --- /dev/null +++ b/Code/Steiner/fractionsSteinerTask/src/Bruch.java @@ -0,0 +1,101 @@ +public class Bruch { + + private int zaehler; + private int nenner; + + Bruch() { + zaehler = 0; + nenner = 1; + } + + Bruch(int x) { + zaehler = x; + nenner = 1; + } + + Bruch(int x, int y) { + zaehler = x; + nenner = y; + } + + void setZaehler(int z) { + zaehler = z; + } + + void setNenner(int n) { + nenner = n; + } + + int getZaehler() { + return zaehler; + } + + int getNenner() { + return nenner; + } + + String bruchToString() { + return zaehler + "/" + nenner; + } + + void ausgeben() { + System.out.println(zaehler + "/" + nenner); + } + + void kuerzen() { + int m, n, r; + m = Math.abs(zaehler); + n = Math.abs(nenner); + r = m % n; + while (r > 0) { + m = n; + n = r; + r = m % n; + } + zaehler /= n; + nenner /= n; + } + + void gekuerztausgeben() { + kuerzen(); + ausgeben(); + } + + Bruch multipliziere(Bruch m) { + var z = zaehler * m.zaehler; + var n = nenner * m.nenner; + return new Bruch(z, n); + } + + boolean equals(Bruch x) { + var a = new Bruch(this.zaehler, this.nenner); + var b = new Bruch(x.zaehler, x.nenner); + a.kuerzen(); + b.kuerzen(); + return (a.zaehler == b.zaehler) && (a.nenner == b.nenner); + } + + // Neue Methode: Addition + Bruch addiere(Bruch b) { + int neuerZaehler = this.zaehler * b.nenner + b.zaehler * this.nenner; + int neuerNenner = this.nenner * b.nenner; + return new Bruch(neuerZaehler, neuerNenner); + } + + // Neue Methode: Subtraktion + Bruch subtrahiere(Bruch b) { + int neuerZaehler = this.zaehler * b.nenner - b.zaehler * this.nenner; + int neuerNenner = this.nenner * b.nenner; + return new Bruch(neuerZaehler, neuerNenner); + } + + // Neue Methode: Dezimalwert + double dezimalwert() { + if (nenner == 0) { + System.out.println("Error Divided by 0"); + return 0; + } else { + return (double) zaehler / nenner; + } + } +} diff --git a/Code/Steiner/fractionsSteinerTask/src/BruchTest.java b/Code/Steiner/fractionsSteinerTask/src/BruchTest.java new file mode 100644 index 0000000..9f3fb6c --- /dev/null +++ b/Code/Steiner/fractionsSteinerTask/src/BruchTest.java @@ -0,0 +1,78 @@ +import java.util.ArrayList; + +public class BruchTest { + public static void main(String[] args) { + ArrayList brueche = new ArrayList<>(); + + // Test 1: Standardkonstruktor + brueche.add(new Bruch()); + System.out.println("Test 1: " + brueche.get(0).bruchToString()); // Erwartet: 0/1 + + // Test 2: Konstruktor mit einem Parameter + brueche.add(new Bruch(3)); + System.out.println("Test 2: " + brueche.get(1).bruchToString()); // Erwartet: 3/1 + + // Test 3: Konstruktor mit zwei Parametern (positive Werte) + brueche.add(new Bruch(4, 8)); + System.out.println("Test 3: " + brueche.get(2).bruchToString()); // Erwartet: 4/8 + brueche.get(2).gekuerztausgeben(); // Erwartet: 1/2 + + // Test 4: Konstruktor mit zwei Parametern (negative Werte) + brueche.add(new Bruch(-4, 8)); + System.out.println("Test 4: " + brueche.get(3).bruchToString()); // Erwartet: -4/8 + brueche.get(3).gekuerztausgeben(); // Erwartet: -1/2 + + // Test 5: Setzen von Zähler und Nenner (normal) + brueche.get(2).setZaehler(6); + brueche.get(2).setNenner(9); + System.out.println("Test 5: " + brueche.get(2).bruchToString()); // Erwartet: 6/9 + brueche.get(2).gekuerztausgeben(); // Erwartet: 2/3 + + // Test 6: Setzen von Zähler und Nenner (mit Null) + brueche.get(2).setZaehler(0); + brueche.get(2).setNenner(9); + System.out.println("Test 6: " + brueche.get(2).bruchToString()); // Erwartet: 0/9 + + // Test 7: Setzen von Zähler und Nenner (Division durch Null) + brueche.get(2).setNenner(0); + System.out.println("Test 7: " + brueche.get(2).bruchToString()); + + // Test 8: Multiplikation + Bruch bruch4 = new Bruch(2, 3); + Bruch produkt = brueche.get(2).multipliziere(bruch4); + System.out.println("Test 8: " + produkt.bruchToString()); // Erwartet: 0/1 + + // Test 9: Gleichheit + Bruch bruch5 = new Bruch(2, 3); + Bruch bruch6 = new Bruch(4, 6); + System.out.println("Test 9: " + bruch5.equals(bruch6)); // Erwartet: true + + // Test 10: Ungleichheit + Bruch bruch7 = new Bruch(1, 2); + System.out.println("Test 10: " + bruch5.equals(bruch7)); // Erwartet: false + + // Test 11: Addition (positive und negative Werte) + Bruch bruch8 = new Bruch(1, 4); + Bruch summe = bruch5.addiere(bruch8); + System.out.println("Test 11: " + summe.bruchToString()); // Erwartet: 11/12 + + // Test 12: Subtraktion (negatives Ergebnis) + Bruch bruch9 = new Bruch(3, 4); + Bruch differenz = bruch5.subtrahiere(bruch9); + System.out.println("Test 12: " + differenz.bruchToString()); // Erwartet: -1/12 + + // Test 13: Dezimalwert + double dezimalwert = bruch5.dezimalwert(); + System.out.println("Test 13: " + dezimalwert); // Erwartet: 0.6666666666666666 (2/3) + + // Test 14: Dezimalwert eines anderen Bruchs + Bruch bruch10 = new Bruch(3, 4); + double dezimalwert2 = bruch10.dezimalwert(); + System.out.println("Test 14: " + dezimalwert2); // Erwartet: 0.75 + + // Test 16: Dezimalwert eines anderen Bruchs (null) + Bruch bruch11 = new Bruch(3, 0); + double dezimalwert3 = bruch11.dezimalwert(); + System.out.println("Test 15: " + dezimalwert3); // Erwartet: 0 + } +} diff --git a/Code/Steiner/interfacesTwoTesting/.vscode/settings.json b/Code/Steiner/interfacesTwoTesting/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/Steiner/interfacesTwoTesting/.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/interfacesTwoTesting/README.md b/Code/Steiner/interfacesTwoTesting/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/Steiner/interfacesTwoTesting/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/interfacesTwoTesting/bin/App.class b/Code/Steiner/interfacesTwoTesting/bin/App.class new file mode 100644 index 0000000..c8204af Binary files /dev/null and b/Code/Steiner/interfacesTwoTesting/bin/App.class differ diff --git a/Code/Steiner/interfacesTwoTesting/bin/Hans.class b/Code/Steiner/interfacesTwoTesting/bin/Hans.class new file mode 100644 index 0000000..69677f3 Binary files /dev/null and b/Code/Steiner/interfacesTwoTesting/bin/Hans.class differ diff --git a/Code/Steiner/interfacesTwoTesting/bin/ISleep.class b/Code/Steiner/interfacesTwoTesting/bin/ISleep.class new file mode 100644 index 0000000..1beb614 Binary files /dev/null and b/Code/Steiner/interfacesTwoTesting/bin/ISleep.class differ diff --git a/Code/Steiner/interfacesTwoTesting/bin/IWalk.class b/Code/Steiner/interfacesTwoTesting/bin/IWalk.class new file mode 100644 index 0000000..12178fc Binary files /dev/null and b/Code/Steiner/interfacesTwoTesting/bin/IWalk.class differ diff --git a/Code/Steiner/interfacesTwoTesting/src/App.java b/Code/Steiner/interfacesTwoTesting/src/App.java new file mode 100644 index 0000000..67852e5 --- /dev/null +++ b/Code/Steiner/interfacesTwoTesting/src/App.java @@ -0,0 +1,6 @@ +public class App { + public static void main(String[] args) throws Exception { + Hans hans = new Hans(); + hans.walk(); + } +} diff --git a/Code/Steiner/interfacesTwoTesting/src/Hans.java b/Code/Steiner/interfacesTwoTesting/src/Hans.java new file mode 100644 index 0000000..7087be1 --- /dev/null +++ b/Code/Steiner/interfacesTwoTesting/src/Hans.java @@ -0,0 +1,8 @@ +public class Hans implements IWalk, ISleep { + + @Override + public void walk() { + System.out.println("Walk"); + } + +} diff --git a/Code/Steiner/interfacesTwoTesting/src/ISleep.java b/Code/Steiner/interfacesTwoTesting/src/ISleep.java new file mode 100644 index 0000000..a0325a4 --- /dev/null +++ b/Code/Steiner/interfacesTwoTesting/src/ISleep.java @@ -0,0 +1,3 @@ +public interface ISleep { + void walk(); +} diff --git a/Code/Steiner/interfacesTwoTesting/src/IWalk.java b/Code/Steiner/interfacesTwoTesting/src/IWalk.java new file mode 100644 index 0000000..88cff8e --- /dev/null +++ b/Code/Steiner/interfacesTwoTesting/src/IWalk.java @@ -0,0 +1,3 @@ +public interface IWalk { + void walk(); +} diff --git a/Code/Steiner/paymentSystemWithInterfaces/.vscode/settings.json b/Code/Steiner/paymentSystemWithInterfaces/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/Steiner/paymentSystemWithInterfaces/.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/paymentSystemWithInterfaces/README.md b/Code/Steiner/paymentSystemWithInterfaces/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/Steiner/paymentSystemWithInterfaces/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/paymentSystemWithInterfaces/bin/App.class b/Code/Steiner/paymentSystemWithInterfaces/bin/App.class new file mode 100644 index 0000000..9fda101 Binary files /dev/null and b/Code/Steiner/paymentSystemWithInterfaces/bin/App.class differ diff --git a/Code/Steiner/paymentSystemWithInterfaces/bin/BankTransferPayment.class b/Code/Steiner/paymentSystemWithInterfaces/bin/BankTransferPayment.class new file mode 100644 index 0000000..2a50e59 Binary files /dev/null and b/Code/Steiner/paymentSystemWithInterfaces/bin/BankTransferPayment.class differ diff --git a/Code/Steiner/paymentSystemWithInterfaces/bin/CreditCardPayment.class b/Code/Steiner/paymentSystemWithInterfaces/bin/CreditCardPayment.class new file mode 100644 index 0000000..8948ff7 Binary files /dev/null and b/Code/Steiner/paymentSystemWithInterfaces/bin/CreditCardPayment.class differ diff --git a/Code/Steiner/paymentSystemWithInterfaces/bin/IPay.class b/Code/Steiner/paymentSystemWithInterfaces/bin/IPay.class new file mode 100644 index 0000000..2b0ff2c Binary files /dev/null and b/Code/Steiner/paymentSystemWithInterfaces/bin/IPay.class differ diff --git a/Code/Steiner/paymentSystemWithInterfaces/bin/PayPalPayment.class b/Code/Steiner/paymentSystemWithInterfaces/bin/PayPalPayment.class new file mode 100644 index 0000000..06eaa48 Binary files /dev/null and b/Code/Steiner/paymentSystemWithInterfaces/bin/PayPalPayment.class differ diff --git a/Code/Steiner/paymentSystemWithInterfaces/bin/Payment.class b/Code/Steiner/paymentSystemWithInterfaces/bin/Payment.class new file mode 100644 index 0000000..4f7d30f Binary files /dev/null and b/Code/Steiner/paymentSystemWithInterfaces/bin/Payment.class differ diff --git a/Code/Steiner/paymentSystemWithInterfaces/src/App.java b/Code/Steiner/paymentSystemWithInterfaces/src/App.java new file mode 100644 index 0000000..8a2e9cd --- /dev/null +++ b/Code/Steiner/paymentSystemWithInterfaces/src/App.java @@ -0,0 +1,24 @@ +public class App { + + public static void main(String[] args) throws Exception { + + Payment creditCard = new CreditCardPayment("1234-5678-9012-3456", "Max Mustermann"); + + Payment paypal = new PayPalPayment("max@example.com"); + + Payment bankTransfer = new BankTransferPayment("DE89 3704 0044 0532 0130 00"); + + processPayment(creditCard, 49.99); + + processPayment(paypal, 19.99); + + processPayment(bankTransfer, 99.99); + + } + + public static void processPayment(Payment payment, double amount) { + payment.pay(amount); + + } + +} \ No newline at end of file diff --git a/Code/Steiner/paymentSystemWithInterfaces/src/BankTransferPayment.java b/Code/Steiner/paymentSystemWithInterfaces/src/BankTransferPayment.java new file mode 100644 index 0000000..3456c5f --- /dev/null +++ b/Code/Steiner/paymentSystemWithInterfaces/src/BankTransferPayment.java @@ -0,0 +1,12 @@ +public class BankTransferPayment extends Payment implements IPay { + String securityNumber; + + public BankTransferPayment(String securityNumber) { + this.securityNumber = securityNumber; + } + + @Override + public void pay(double amount) { + System.out.println("Bezahlung von " + amount + " CHF mit Banktransfer " + securityNumber); + } +} diff --git a/Code/Steiner/paymentSystemWithInterfaces/src/CreditCardPayment.java b/Code/Steiner/paymentSystemWithInterfaces/src/CreditCardPayment.java new file mode 100644 index 0000000..50d7a4c --- /dev/null +++ b/Code/Steiner/paymentSystemWithInterfaces/src/CreditCardPayment.java @@ -0,0 +1,14 @@ +public class CreditCardPayment extends Payment implements IPay { + String number; + String name; + + public CreditCardPayment(String number, String name) { + this.number = number; + this.name = name; + } + + @Override + public void pay(double amount) { + System.out.println("Bezahlung von " + amount + " CHF mit Kreditkarte " + number + " von " + name); + } +} diff --git a/Code/Steiner/paymentSystemWithInterfaces/src/IPay.java b/Code/Steiner/paymentSystemWithInterfaces/src/IPay.java new file mode 100644 index 0000000..2a37728 --- /dev/null +++ b/Code/Steiner/paymentSystemWithInterfaces/src/IPay.java @@ -0,0 +1,3 @@ +public interface IPay { + public void pay(double amount); +} diff --git a/Code/Steiner/paymentSystemWithInterfaces/src/PayPalPayment.java b/Code/Steiner/paymentSystemWithInterfaces/src/PayPalPayment.java new file mode 100644 index 0000000..ab4dff7 --- /dev/null +++ b/Code/Steiner/paymentSystemWithInterfaces/src/PayPalPayment.java @@ -0,0 +1,12 @@ +public class PayPalPayment extends Payment implements IPay { + String mail; + + public PayPalPayment(String mail) { + this.mail = mail; + } + + @Override + public void pay(double amount) { + System.out.println("Bezahlung von " + amount + " CHF mit Kreditkarte " + mail); + } +} diff --git a/Code/Steiner/paymentSystemWithInterfaces/src/Payment.java b/Code/Steiner/paymentSystemWithInterfaces/src/Payment.java new file mode 100644 index 0000000..8dba32a --- /dev/null +++ b/Code/Steiner/paymentSystemWithInterfaces/src/Payment.java @@ -0,0 +1,3 @@ +public abstract class Payment implements IPay { + public abstract void pay(double amount); +} diff --git a/Code/Steiner/tryCatchTask/.vscode/settings.json b/Code/Steiner/tryCatchTask/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/Steiner/tryCatchTask/.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/tryCatchTask/README.md b/Code/Steiner/tryCatchTask/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/Steiner/tryCatchTask/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/tryCatchTask/bin/App.class b/Code/Steiner/tryCatchTask/bin/App.class new file mode 100644 index 0000000..f809a66 Binary files /dev/null and b/Code/Steiner/tryCatchTask/bin/App.class differ diff --git a/Code/Steiner/tryCatchTask/src/App.java b/Code/Steiner/tryCatchTask/src/App.java new file mode 100644 index 0000000..12ad158 --- /dev/null +++ b/Code/Steiner/tryCatchTask/src/App.java @@ -0,0 +1,28 @@ +import java.io.*; + +public class App { + + public static void main(String[] args) { + try { + readFile("test.txt"); + } catch (FileNotFoundException e) { + System.err.println("Error: The file was not found. Please check the file path."); + } catch (IOException e) { + System.err.println("Error: An I/O error occurred while reading the file."); + } catch (Exception e) { + System.err.println("An unexpected error occurred: " + e.getMessage()); + } + } + + private static void readFile(String fileName) throws IOException { + FileReader f = new FileReader(fileName); + try { + int c; + while ((c = f.read()) != -1) { + System.out.print((char) c); + } + } finally { + f.close(); + } + } +} diff --git a/Code/Steiner/tryCatchTask/test.txt b/Code/Steiner/tryCatchTask/test.txt new file mode 100644 index 0000000..885e1ff --- /dev/null +++ b/Code/Steiner/tryCatchTask/test.txt @@ -0,0 +1,22 @@ +🎉 Super! 🎉 + +Du hast es geschafft. + +Herzliche Gratulation! + +🌟 STEINER 🌟 + +Ein Hauch von Magie in der Luft! + +✨ Die Sterne funkeln, während die Gedanken fliegen. ✨ + +🔮 Zufällige Gedanken: + + Kaffeetassen tanzen im Regen. + Ein fliegender Teppich voller Bücher. + Die Farben des Windes singen Lieder. + +🌈 Lass die Kreativität sprudeln! + + Was wäre, wenn die Fische die Wolken fangen könnten? + Ein Abenteuer im Land der Träume wartet auf dich!