diff --git a/.vscode/settings.json b/Code/16.01.24 PrüfungJava/.vscode/settings.json similarity index 70% rename from .vscode/settings.json rename to Code/16.01.24 PrüfungJava/.vscode/settings.json index 3652cd9..e112a70 100644 --- a/.vscode/settings.json +++ b/Code/16.01.24 PrüfungJava/.vscode/settings.json @@ -3,6 +3,5 @@ "java.project.outputPath": "bin", "java.project.referencedLibraries": [ "lib/**/*.jar" - ], - "java.format.settings.url": "eclipse-formatter.xml" + ] } diff --git a/README.md b/Code/16.01.24 PrüfungJava/README.md similarity index 100% rename from README.md rename to Code/16.01.24 PrüfungJava/README.md diff --git a/Code/16.01.24 PrüfungJava/bin/App.class b/Code/16.01.24 PrüfungJava/bin/App.class new file mode 100644 index 0000000..1260e7f Binary files /dev/null and b/Code/16.01.24 PrüfungJava/bin/App.class differ diff --git a/Code/16.01.24 PrüfungJava/src/App.java b/Code/16.01.24 PrüfungJava/src/App.java new file mode 100644 index 0000000..c02a9d2 --- /dev/null +++ b/Code/16.01.24 PrüfungJava/src/App.java @@ -0,0 +1,62 @@ +// Luca Fabian Burger +// Aufgabe 3 + +public class App { + public static void main(String[] args) throws Exception { + int[] sitzPlaetze = new int[100]; + sitzPlaetze[1] = 45; + sitzPlaetze[17] = 12; + sitzPlaetze[32] = 25; + sitzPlaetze[45] = 54; + sitzPlaetze[85] = 88; + + double durchscnittalter = getAvarageAge(sitzPlaetze); + int[] belegteSitze = getBelegteSitze(sitzPlaetze); + int youngestAge = getYoungestAge(sitzPlaetze, belegteSitze); + printOut("Das durchscnittliche Alter ist : ", durchscnittalter); + printOut("Das jüngste Alter ist : ", youngestAge); + + } + + public static int[] getBelegteSitze(int[] sitzPlaetze) { + int controllNumber = 0; + int[] belegteSitze = new int[sitzPlaetze.length]; + for (int i = 0; i < sitzPlaetze.length; i++) { + if (sitzPlaetze[i] > 0) { + belegteSitze[controllNumber] = i; + controllNumber++; + } + } + return belegteSitze; + } + + public static double getAvarageAge(int[] sitzPlaetze) { + double avarageAge = 0; + int anzahlBesucher = 0; + + for (int i = 0; i < sitzPlaetze.length; i++) { + if (sitzPlaetze[i] > 0) { + avarageAge += sitzPlaetze[i]; + anzahlBesucher++; + } + } + return avarageAge / anzahlBesucher; + } + + public static int getYoungestAge(int[] sitzPlaetze, int[] belegteSitze) { + int youngestAge = 100000; + for (int i = 0; i < belegteSitze.length; i++) { + for (int o = 0; o < belegteSitze.length; o++) { + if (sitzPlaetze[i] < youngestAge && sitzPlaetze[i] != 0) { + youngestAge = sitzPlaetze[i]; + } + } + } + return youngestAge; + + } + + public static void printOut(String myText, double myValue) { + System.out.println(myText + myValue); + } +} \ No newline at end of file diff --git a/Code/2dArrays/.vscode/settings.json b/Code/2dArrays/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/2dArrays/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/2dArrays/README.md b/Code/2dArrays/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/2dArrays/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/2dArrays/bin/App.class b/Code/2dArrays/bin/App.class new file mode 100644 index 0000000..a92edf8 Binary files /dev/null and b/Code/2dArrays/bin/App.class differ diff --git a/Code/2dArrays/src/App.class b/Code/2dArrays/src/App.class new file mode 100644 index 0000000..92559f7 Binary files /dev/null and b/Code/2dArrays/src/App.class differ diff --git a/Code/2dArrays/src/App.java b/Code/2dArrays/src/App.java new file mode 100644 index 0000000..a8dc5fc --- /dev/null +++ b/Code/2dArrays/src/App.java @@ -0,0 +1,35 @@ +public class App { + + public static void main(String[] args) { + int[][] matrix1 = { + // x 0 1 2 + { 1, 2, 3 }, // 0 + { 4, 5, 6 }, // 1 + { 7, 8, 9 } // 2 y + }; + + int[][] matrix2 = { + { 9, 8, 7 }, + { 6, 5, 4 }, + { 3, 2, 1 } + }; + + System.out.println(matrix1[1][2]); + System.out.println(matrix2[1][2]); + + int[][] sumMatrix = new int[matrix1.length][matrix1.length]; + + for (int i = 0; i < matrix1.length; i++) { + for (int j = 0; j < matrix1[i].length; j++) { + sumMatrix[j][i] = matrix1[j][i] + matrix2[j][i]; + } + } + + for (int i = 0; i < matrix1.length; i++) { + for (int j = 0; j < matrix1[i].length; j++) { + System.out.print(sumMatrix[i][j] + " "); + } + System.out.println(""); + } + } +} \ No newline at end of file diff --git a/Code/30.8.23/.vscode/settings.json b/Code/30.8.23/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/30.8.23/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/30.8.23/README.md b/Code/30.8.23/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/30.8.23/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/30.8.23/bin/App.class b/Code/30.8.23/bin/App.class new file mode 100644 index 0000000..745b8af Binary files /dev/null and b/Code/30.8.23/bin/App.class differ diff --git a/Code/30.8.23/src/App.java b/Code/30.8.23/src/App.java new file mode 100644 index 0000000..d63a256 --- /dev/null +++ b/Code/30.8.23/src/App.java @@ -0,0 +1,17 @@ +import java.util.Scanner; + +public class App { + static Scanner scan = new Scanner(System.in); + + public static void main(String[] args) throws Exception { + int myNumber = 12; + System.out.println("Please type a number to add:"); + int numberToAdd = scan.nextInt(); + + myNumber += numberToAdd; + + System.out.println(myNumber); + + scan.close(); + } +} diff --git a/Code/5.12.23-JavaExam3/.vscode/settings.json b/Code/5.12.23-JavaExam3/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/5.12.23-JavaExam3/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/5.12.23-JavaExam3/README.md b/Code/5.12.23-JavaExam3/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/5.12.23-JavaExam3/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/5.12.23-JavaExam3/bin/App.class b/Code/5.12.23-JavaExam3/bin/App.class new file mode 100644 index 0000000..3772d15 Binary files /dev/null and b/Code/5.12.23-JavaExam3/bin/App.class differ diff --git a/Code/5.12.23-JavaExam3/src/App.java b/Code/5.12.23-JavaExam3/src/App.java new file mode 100644 index 0000000..9b81004 --- /dev/null +++ b/Code/5.12.23-JavaExam3/src/App.java @@ -0,0 +1,37 @@ +// Luca Fabian Burger +// Aufgabe 11 + +public class App { + + public static void main(String[] args) throws Exception { + + // Dreiecks-Berechnungen nach Pythagoras + // hypo meint Hypothenuse + + // Dreieck 1 + double seiteA1 = 3; + double seiteB1 = 4; + double hypo1 = getHypo(seiteA1, seiteB1); + printHypo(hypo1, "Erstes Dreieck"); + + // Dreieck 2 + double seiteA2 = 4; + double seiteB2 = 5; + double hypo2 = getHypo(seiteA2, seiteB2); + printHypo(hypo2, "Zweites Dreieck"); + + // Dreieck 3 + double seiteA3 = 5; + double seiteB3 = 6; + double hypo3 = getHypo(seiteA3, seiteB3); + printHypo(hypo3, "Drittes Dreieck"); + } + + public static double getHypo(double seiteA, double seiteB) { + return Math.sqrt(seiteA * seiteA + seiteB * seiteB); + } + + public static void printHypo(double hypo, String myText) { + System.out.println(myText + ": " + hypo); + } +} diff --git a/Code/Boolean/.vscode/settings.json b/Code/Boolean/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/Boolean/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/Boolean/README.md b/Code/Boolean/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/Boolean/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/Boolean/bin/App.class b/Code/Boolean/bin/App.class new file mode 100644 index 0000000..b64da87 Binary files /dev/null and b/Code/Boolean/bin/App.class differ diff --git a/Code/Boolean/src/App.java b/Code/Boolean/src/App.java new file mode 100644 index 0000000..1acd8cd --- /dev/null +++ b/Code/Boolean/src/App.java @@ -0,0 +1,15 @@ +public class App { + public static void main(String[] args) throws Exception { + + boolean a = 1 == 1; + boolean b = 1 != 2; + boolean c = a == b; + boolean d = c != b; + + if (d) { + System.out.println("d is true see: " + d); + } else { + System.out.println("d is false see: " + d); + } + } +} diff --git a/Code/Debuging_Prüfungen/debuging/.vscode/settings.json b/Code/Debuging_Prüfungen/debuging/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/Debuging_Prüfungen/debuging/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/Debuging_Prüfungen/debuging/README.md b/Code/Debuging_Prüfungen/debuging/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/Debuging_Prüfungen/debuging/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/Debuging_Prüfungen/debuging/bin/App.class b/Code/Debuging_Prüfungen/debuging/bin/App.class new file mode 100644 index 0000000..4b8f071 Binary files /dev/null and b/Code/Debuging_Prüfungen/debuging/bin/App.class differ diff --git a/Code/Debuging_Prüfungen/debuging/src/App.java b/Code/Debuging_Prüfungen/debuging/src/App.java new file mode 100644 index 0000000..5bbc8f3 --- /dev/null +++ b/Code/Debuging_Prüfungen/debuging/src/App.java @@ -0,0 +1,27 @@ +// Luca Fabian Burger +// Aufgabe 13 +// Die Eingabe von Fliesskomazahlen funktioniert nicht + +import java.util.Scanner; + +public class App { + static Scanner scan = new Scanner(System.in); + + public static void main(String[] args) { + + System.out.println("Was ist dein Vorname?"); + String vorname = scan.next(); + + System.out.println("Wie schwer sind Sie in KG? (mit Kommastellen)"); + double gewicht = scan.nextDouble(); + + System.out.println("Wie gross sind Sie in Meter (mit Kommastellen)"); + double groesse = scan.nextDouble(); + + double bmi = gewicht / (groesse * groesse); + + System.out.println("Lieber " + vorname + " dein BMI beträgt: " + bmi); + + scan.close(); + } +} diff --git a/Code/Exchange/.vscode/settings.json b/Code/Exchange/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/Exchange/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/Exchange/README.md b/Code/Exchange/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/Exchange/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/Exchange/bin/App.class b/Code/Exchange/bin/App.class new file mode 100644 index 0000000..0333d9b Binary files /dev/null and b/Code/Exchange/bin/App.class differ diff --git a/src/Archiv/exchange.java b/Code/Exchange/src/App.java similarity index 55% rename from src/Archiv/exchange.java rename to Code/Exchange/src/App.java index 0066118..9375bb4 100644 --- a/src/Archiv/exchange.java +++ b/Code/Exchange/src/App.java @@ -1,22 +1,24 @@ -package Archiv; +import java.util.Scanner; -public class exchange { - public static void main(String[] args) { +public class App { + static Scanner scan = new Scanner(System.in); - int x = 5; - int y = 7; + public static void main(String[] args) throws Exception { + System.out.println("Define the variable x, if you would be so kind:"); + int x = scan.nextInt(); + System.out.println("now again for y, please:"); + int y = scan.nextInt(); - // Vor dem Tausch + System.out.println("Before the exchange"); System.out.println(x); System.out.println(y); - // Tausch - int z = 0; - z = x; + // Exchange + int z = x; x = y; y = z; - // Nach dem Tausch + System.out.println("after the exchange"); System.out.println(x); System.out.println(y); @@ -29,5 +31,7 @@ public class exchange { * Sie dürfen nur Code zwischen den beiden Kommentaren //Tausch * und //Nach dem Tausch hinzufügen! */ + + scan.close(); } } \ No newline at end of file diff --git a/Code/Geografie/.vscode/settings.json b/Code/Geografie/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/Geografie/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/Geografie/README.md b/Code/Geografie/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/Geografie/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/Geografie/bin/App.class b/Code/Geografie/bin/App.class new file mode 100644 index 0000000..8e2224c Binary files /dev/null and b/Code/Geografie/bin/App.class differ diff --git a/Code/Geografie/src/App.java b/Code/Geografie/src/App.java new file mode 100644 index 0000000..4adeb2e --- /dev/null +++ b/Code/Geografie/src/App.java @@ -0,0 +1,95 @@ +import java.util.Scanner; + +public class App { + static Scanner scan = new Scanner(System.in); + + public static void main(String[] args) throws Exception { + + // variables for score + double question = 0; + final double QuestionTotal = 6; + double grade = 1; + + // Anwsers + System.out.println("is Sargans in Graubünden? y/n"); + String anwserOne = scan.nextLine(); + System.out.println("Is Lichtenstein bigger than St. Gallen? y/n"); + String anwserTwo = scan.nextLine(); + System.out.println("is Bielefeld real? y/n"); + String anwserThree = scan.nextLine(); + System.out.println("Is St. Moritz in Switzerland y/n"); + String anwserFor = scan.nextLine(); + System.out.println("Has Lichtenstein a own army y/n"); + String anwserFive = scan.nextLine(); + System.out.println("Is the Matterhorn a mountain y/n"); + String anwserSix = scan.nextLine(); + + // correction + if (anwserOne.equalsIgnoreCase("n")) { + question++; + } + if (anwserTwo.equalsIgnoreCase("n")) { + question++; + } + if (anwserThree.equalsIgnoreCase("n")) { + question++; + } + if (anwserFor.equalsIgnoreCase("y")) { + question++; + } + if (anwserFive.equalsIgnoreCase("n")) { + question++; + } + if (anwserSix.equalsIgnoreCase("y")) { + question++; + } + + // Score + grade = question / QuestionTotal * 5 + 1; + + /* + * // Rounding + * if (grade >= 1 && grade < 1.5) { + * grade = 1; + * } else if (grade >= 1.5 && grade < 2.5) { + * grade = 2; + * } else if (grade >= 2.5 && grade < 3.5) { + * grade = 3; + * } else if (grade >= 3.5 && grade < 4.5) { + * grade = 4; + * } else if (grade >= 4.5 && grade < 5) { + * grade = 5; + * } + */ + + // text feedback + switch ((int) grade) { + case 1: + System.out.println("Ouh tuff buddy"); + break; + case 2: + System.out.println("Please learn more"); + break; + case 3: + System.out.println("So close buddy"); + break; + case 4: + System.out.println("Good job Buddy"); + break; + case 5: + double distantToPerfection = (double) 6 - grade; + System.out.println("Absolut Mastermind only " + distantToPerfection + " short to perfection"); + break; + case 6: + System.out.println("Mastermind"); + break; + default: + System.out.println("Error"); + break; + } + + System.out.println("In other words your grade is: " + grade); + scan.close(); + + } +} diff --git a/Code/IMS-java b/Code/IMS-java new file mode 160000 index 0000000..d3092e6 --- /dev/null +++ b/Code/IMS-java @@ -0,0 +1 @@ +Subproject commit d3092e64bf931d5b98fa000fca03fa1069647646 diff --git a/Code/MATHE/.vscode/settings.json b/Code/MATHE/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/MATHE/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/MATHE/README.md b/Code/MATHE/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/MATHE/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/MATHE/bin/App.class b/Code/MATHE/bin/App.class new file mode 100644 index 0000000..8bd7b18 Binary files /dev/null and b/Code/MATHE/bin/App.class differ diff --git a/Code/MATHE/src/App.java b/Code/MATHE/src/App.java new file mode 100644 index 0000000..31947b8 --- /dev/null +++ b/Code/MATHE/src/App.java @@ -0,0 +1,37 @@ +// Alle Brechnungen mit der Annahme Juni und schönes Wetter +public class App { + public static void main(String[] args) throws Exception { + + // Grösse der Fahrzeuge + double pkw = 2.2; + // Lastwagen und Büsse + double lastwagen = 10; + double mottorad = 1.8; + + // Wahrscheinschlichkeit + double waPkw = 70; + double waLastwagen = 15; + double waMottorad = 15; + + // Strecke + double laenge = 6000; + double spuren = 2; + + // brechnungen + + // Strecke + double strecke = laenge * spuren; + + // durchscnittliche länge + // plus 6 2m abstand für 3 fahrzeuge + double anzahl = (pkw * waPkw + lastwagen * waLastwagen + mottorad * waMottorad + 6) / 100; + + // durschnittliche länge + System.err.println(anzahl); + + // verrechnung + int fahrzeuge = (int) (strecke / anzahl); + System.out.println("Die durchsnittliche anzahl Fahrzeuge für eine Staustrecke von " + laenge + "beträgt: " + + fahrzeuge); + } +} diff --git a/Code/Uhrzeiten/Time/.vscode/settings.json b/Code/Uhrzeiten/Time/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/Uhrzeiten/Time/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/Uhrzeiten/Time/README.md b/Code/Uhrzeiten/Time/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/Uhrzeiten/Time/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/Uhrzeiten/Time/bin/App.class b/Code/Uhrzeiten/Time/bin/App.class new file mode 100644 index 0000000..9ef6d63 Binary files /dev/null and b/Code/Uhrzeiten/Time/bin/App.class differ diff --git a/Code/Uhrzeiten/Time/src/App.java b/Code/Uhrzeiten/Time/src/App.java new file mode 100644 index 0000000..17d35b6 --- /dev/null +++ b/Code/Uhrzeiten/Time/src/App.java @@ -0,0 +1,39 @@ + +/* + * Bis 8:00 Morgen --> morning + * Bis 12:00 Vormittag --> late noon + * bis 15:59 Nachmittag --> afternoon + * 16:00 Zvieri --> "Zvieri" + * bis 21:00 Abend --> Evening + * bis 00:00 Nacht --> Night + */ + +import java.util.Scanner; + +public class App { + static Scanner scan = new Scanner(System.in); + + public static void main(String[] args) throws Exception { + System.out.println( + "What time is it (you can use any DECIMAL number but use \",\" for decimal numbers please my terminal is acting funky idk why frfr)"); + double localTime = scan.nextDouble(); + + if (localTime < (double) 0) { + System.out.println("I don't think that's true"); + } else if (localTime > (double) 24) { + System.out.println("Where do you live, my guy?"); + } else if (localTime == (double) 16) { + System.out.println("It's Zvieri"); + } else if (localTime <= (double) 8) { + System.out.println("It's morning"); + } else if (localTime <= (double) 12) { + System.out.println("It's late morning"); + } else if (localTime <= (double) 15) { + System.out.println("It's noon"); + } else if (localTime <= (double) 21) { + System.out.println("It's evening"); + } else { + System.out.println("It's night"); + } + } +} diff --git a/Code/Variablen_Deklarieren/variablen-deklarieren/.vscode/settings.json b/Code/Variablen_Deklarieren/variablen-deklarieren/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/Variablen_Deklarieren/variablen-deklarieren/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/Variablen_Deklarieren/variablen-deklarieren/README.md b/Code/Variablen_Deklarieren/variablen-deklarieren/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/Variablen_Deklarieren/variablen-deklarieren/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/Variablen_Deklarieren/variablen-deklarieren/bin/App.class b/Code/Variablen_Deklarieren/variablen-deklarieren/bin/App.class new file mode 100644 index 0000000..2bcaf20 Binary files /dev/null and b/Code/Variablen_Deklarieren/variablen-deklarieren/bin/App.class differ diff --git a/Code/Variablen_Deklarieren/variablen-deklarieren/src/App.java b/Code/Variablen_Deklarieren/variablen-deklarieren/src/App.java new file mode 100644 index 0000000..76be2ac --- /dev/null +++ b/Code/Variablen_Deklarieren/variablen-deklarieren/src/App.java @@ -0,0 +1,44 @@ +public class App { + public static void main(String[] args) throws Exception { + + // Variables + byte byteLuca; + short shortLuca; + int intLuca; + long longLuca; + float floatLuca; + double doubleLuca; + + // Strings to shorten the text + String a = "\"byteLuca\""; + String b = "\"shortLuca\""; + String c = "\"intLuca\""; + String d = "\"longLuca\""; + String e = "\"floatLuca\""; + String f = "\"doubleLuca\""; + String g = "This is the worth of variable "; + String h = " from the category "; + + // Worth + byteLuca = 127; + shortLuca = 128; + intLuca = 999; + longLuca = 878897; + floatLuca = 3.54325f; + doubleLuca = 3.35355353; + + // Text block + "Datetype" + category: worth + System.out.println(g + a + h + "byte: " + byteLuca); + System.out.println(g + b + h + "short: " + shortLuca); + System.out.println(g + c + h + "int: " + intLuca); + System.out.println(g + d + h + "long: " + longLuca); + System.out.println(g + e + h + "float: " + floatLuca); + System.out.println(g + f + h + "double: " + doubleLuca); + + /* + * + * This comment just demonstrates that i can comment throw multible lines + * There's no other use for this, please ignore, thank you + */ + } +} diff --git a/Code/Variablen_sortieren/.vscode/settings.json b/Code/Variablen_sortieren/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/Variablen_sortieren/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/Variablen_sortieren/README.md b/Code/Variablen_sortieren/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/Variablen_sortieren/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/Variablen_sortieren/bin/Input.class b/Code/Variablen_sortieren/bin/Input.class new file mode 100644 index 0000000..d1e6a1d Binary files /dev/null and b/Code/Variablen_sortieren/bin/Input.class differ diff --git a/bin/Archiv/Sort.class b/Code/Variablen_sortieren/bin/Zufall.class similarity index 68% rename from bin/Archiv/Sort.class rename to Code/Variablen_sortieren/bin/Zufall.class index 2913930..6c40814 100644 Binary files a/bin/Archiv/Sort.class and b/Code/Variablen_sortieren/bin/Zufall.class differ diff --git a/Code/Variablen_sortieren/src/Input.java b/Code/Variablen_sortieren/src/Input.java new file mode 100644 index 0000000..620348f --- /dev/null +++ b/Code/Variablen_sortieren/src/Input.java @@ -0,0 +1,46 @@ +import java.util.Scanner; + +public class Input { + static Scanner scan = new Scanner(System.in); + + public static void main(String[] args) throws Exception { + + System.out.println("Zahl 1:"); + int numberOne = scan.nextInt(); + + System.out.println("Zahl 2:"); + int numberTwo = scan.nextInt(); + + System.out.println("Zahl 3:"); + int numberThree = scan.nextInt(); + + System.out.println("a equals: " + numberOne); + System.out.println("b equals: " + numberTwo); + System.out.println("c equals: " + numberThree); + + /* + * Deaktiviert da ich das logische Und noch nicht kennen darf + * + * if (numberOne > numberTwo && numberOne > numberThree) { + * System.out.println("The largest variable is: a"); + * } else if (numberTwo > numberOne && numberTwo > numberThree) { + * System.out.println("The largest variable is: b"); + * } else if (numberThree > numberOne && numberThree > numberTwo) { + * System.out.println("The largest variable is: c"); + * } else + * System.out.println("All variables have the same value"); + */ + + if (numberOne > numberTwo) { + if (numberOne > numberThree) { + System.out.println(numberOne + " (aka a) is the biggest"); + } + } else if (numberTwo > numberThree) { + System.out.println(numberTwo + " (aka b) is the biggest"); + } else if (numberThree != numberOne) { + System.out.println(numberThree + " (aka c) is the biggest"); + } else { + System.out.println("all variables are the same thing"); + } + } +} \ No newline at end of file diff --git a/src/Archiv/Sort.java b/Code/Variablen_sortieren/src/Zufall.java similarity index 96% rename from src/Archiv/Sort.java rename to Code/Variablen_sortieren/src/Zufall.java index 52babb2..4ee3ab1 100644 --- a/src/Archiv/Sort.java +++ b/Code/Variablen_sortieren/src/Zufall.java @@ -1,8 +1,6 @@ -package Archiv; - import java.util.Random; -public class Sort { +public class Zufall { public static void main(String[] args) throws Exception { // Creating a Random object Random random = new Random(); @@ -28,6 +26,5 @@ public class Sort { System.out.println("The largest variable is: c"); } else System.out.println("All variables have the same value"); - } } diff --git a/Code/arraysPractice/.vscode/settings.json b/Code/arraysPractice/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/arraysPractice/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/arraysPractice/README.md b/Code/arraysPractice/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/arraysPractice/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/arraysPractice/bin/App.class b/Code/arraysPractice/bin/App.class new file mode 100644 index 0000000..40498e6 Binary files /dev/null and b/Code/arraysPractice/bin/App.class differ diff --git a/Code/arraysPractice/src/App.java b/Code/arraysPractice/src/App.java new file mode 100644 index 0000000..4bcc0f5 --- /dev/null +++ b/Code/arraysPractice/src/App.java @@ -0,0 +1,25 @@ +public class App { + public static void main(String[] args) throws Exception { + double[] arr = new double[1000]; + + for (int i = 0; i < arr.length; i++) { + arr[i] = 0.1; + } + + String student[] = { "Gianna", "Niki", "Luca", "Yasin", "Andi", "Beis", "Stipe", "Patrick", "Andrin", "Yasin" }; + System.out.println("The class has: " + student.length + " students"); + + for (int i = 0; i < arr.length; i++) { + arr[i] = arr[i] + 4.12; + arr[i] = arr[i] + i; + } + + for (int i = 0; i < arr.length; i++) { + System.out.println(arr[i]); + } + + for (int i = 0; i < student.length; i++) { + System.out.println("Student with the index " + i + " is called: " + student[i]); + } + } +} diff --git a/Code/arraysTest/.vscode/settings.json b/Code/arraysTest/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/arraysTest/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/arraysTest/README.md b/Code/arraysTest/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/arraysTest/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/arraysTest/bin/App.class b/Code/arraysTest/bin/App.class new file mode 100644 index 0000000..ee9f828 Binary files /dev/null and b/Code/arraysTest/bin/App.class differ diff --git a/Code/arraysTest/src/App.java b/Code/arraysTest/src/App.java new file mode 100644 index 0000000..4b51efc --- /dev/null +++ b/Code/arraysTest/src/App.java @@ -0,0 +1,14 @@ +public class App { + public static void main(String[] args) throws Exception { + int[] numbersForMath = new int[3]; + numbersForMath[0] = 24; + numbersForMath[1] = 56; + int sum = calcSum(numbersForMath[0], numbersForMath[1]); + System.out.println(sum); + System.out.println(numbersForMath[2]); + } + + public static int calcSum(int numberOne, int numberTwo) { + return numberOne + numberTwo; + } +} diff --git a/Code/aufgabeZwei/.vscode/settings.json b/Code/aufgabeZwei/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/aufgabeZwei/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/aufgabeZwei/README.md b/Code/aufgabeZwei/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/aufgabeZwei/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/aufgabeZwei/bin/App.class b/Code/aufgabeZwei/bin/App.class new file mode 100644 index 0000000..3c2590f Binary files /dev/null and b/Code/aufgabeZwei/bin/App.class differ diff --git a/Code/aufgabeZwei/src/App.java b/Code/aufgabeZwei/src/App.java new file mode 100644 index 0000000..a55d803 --- /dev/null +++ b/Code/aufgabeZwei/src/App.java @@ -0,0 +1,41 @@ +// Luca Burger +// Aufgabe 2 + +import java.util.Scanner; + +public class App { + static Scanner scan = new Scanner(System.in); + + public static void main(String[] args) throws Exception { + System.out.println("Wie schwer ist die Sendung (in g)"); + int gewicht = scan.nextInt(); + boolean individuelleBriefmarke = false; + + if (gewicht <= 50 && gewicht > 0) { + System.out.println("Soll die Sendung versichert werden?"); + if (versichert.equalsIgnoreCase("j")) { + System.out.println("Standartbrief versichert"); + } else { + System.out.println("Standartbrief unversichert"); + } + } else if (gewicht > 50 && gewicht <= 100) { + System.out.println("Soll die Sendung versichert werden?"); + String versichert2 = scan.nextLine(); + if (versichert2.equalsIgnoreCase("j")) { + System.out.println("Kompaktbrief versichert"); + } else { + System.out.println("Kopaktbrief unversichert"); + } + System.out.println("Möchten Sie eine Individuelle Briefmarke?"); + String frage = scan.nextLine(); + if (frage.equalsIgnoreCase("j")) { + individuelleBriefmarke = true; + } + } else if (gewicht <= 500) { + System.out.println("Grossbrief"); + } else { + System.out.println("Sendung weiterleiten an Paketstation"); + } + System.out.println("BESTEN Dank für die Sendungsaufgabe wir wünschen Ihnen..."); + } +} diff --git a/Code/battleShip/.vscode/settings.json b/Code/battleShip/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/battleShip/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/battleShip/README.md b/Code/battleShip/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/battleShip/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/battleShip/bin/App.class b/Code/battleShip/bin/App.class new file mode 100644 index 0000000..d1d7610 Binary files /dev/null and b/Code/battleShip/bin/App.class differ diff --git a/Code/battleShip/bin/test.class b/Code/battleShip/bin/test.class new file mode 100644 index 0000000..7ae4b12 Binary files /dev/null and b/Code/battleShip/bin/test.class differ diff --git a/Code/battleShip/notes/battleShip-V2.pap b/Code/battleShip/notes/battleShip-V2.pap new file mode 100644 index 0000000..b16a6bd --- /dev/null +++ b/Code/battleShip/notes/battleShip-V2.pap @@ -0,0 +1,581 @@ + + + + + + + + +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+
+ + + + + + + + + + + + + + +
+ + + + +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+
+ + + + + + + + + +
+ + + + +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+
+ + + + + + + + + + + + + + + +
+ + + + +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+
+ + + +
+
+
+ \ No newline at end of file diff --git a/Code/battleShip/notes/battleShip.pap b/Code/battleShip/notes/battleShip.pap new file mode 100644 index 0000000..a31f9ad --- /dev/null +++ b/Code/battleShip/notes/battleShip.pap @@ -0,0 +1,377 @@ + + + + + + + + +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+
+ + + + + + + + + + + + + + + +
+
+
+ \ No newline at end of file diff --git a/Code/battleShip/notes/board.txt b/Code/battleShip/notes/board.txt new file mode 100644 index 0000000..ffaed29 --- /dev/null +++ b/Code/battleShip/notes/board.txt @@ -0,0 +1,44 @@ + | A | B | C | D | E | F | G | H | I | J | +-------------------------------------------- + 1 | | | | | | | | | | | +-------------------------------------------- + 2 | | | | | | | | | | | +-------------------------------------------- + 3 | | | | | | | | | | | +-------------------------------------------- + 4 | | | | | | | | | | | +-------------------------------------------- + 5 | | | | | | | | | | | +-------------------------------------------- + 6 | | | | | | | | | | | +-------------------------------------------- + 7 | | | | | | | | | | | +-------------------------------------------- + 8 | | | | | | | | | | | +-------------------------------------------- + 9 | | | | | | | | | | | +-------------------------------------------- +10 | | | | | | | | | | | +-------------------------------------------- + + + + + + + + + + + + + + + + + + + + + +| | | | | | | | | | . \ No newline at end of file diff --git a/Code/battleShip/src/App.class b/Code/battleShip/src/App.class new file mode 100644 index 0000000..a7fc5b4 Binary files /dev/null and b/Code/battleShip/src/App.class differ diff --git a/Code/battleShip/src/App.java b/Code/battleShip/src/App.java new file mode 100644 index 0000000..a9ebb0f --- /dev/null +++ b/Code/battleShip/src/App.java @@ -0,0 +1,349 @@ +import java.util.Random; +import java.util.Scanner; + +public class App { + // Board chars + public static final int BLANK = 0; // ' ' + public static final int WATER = 1; // 'O' + public static final int SHIP = 2; // 'X' + public static final int SUNK = 3; // 'S' + public static final int HIDDEN_SHIP = 4; // ' ' + public static final int REVEALED_SHIP = 5; // 'R' + + // board[vertical desc --> y][horizontal left to right --> x] + public static int[][] board = new int[10][10]; + + // Array where the ships are stored + private static int[] shipX = new int[10]; + private static int[] shipY = new int[10]; + private static boolean[] shipDirection = new boolean[10]; + private static int[] shipLength = new int[10]; + + // Number of shots fired + public static int firedShot = 0; + public static boolean game = true; + + public static void main(String[] args) { + boolean areShipsRevealed = false; + // Explanation rules + initializeGame(); + do { + printBoard(); + System.out.println("Where do you want to shoot? (e.g., A5 or ? for a tip or -1 to end the game) "); + String input = getCoordinates(); + + switch (input) { + case "-1": + game = false; + break; + case "?": + revealHiddenShips(); + areShipsRevealed = true; + break; + default: + // The Lines 47-49 should be deactivated while debugging to make it easier + if (areShipsRevealed) { + hideRevealedShips(); + } + handleShot(input); + break; + } + } while (game); + } + + // Handles the player's shot input, validates it, and processes the shot. + private static void handleShot(String input) { + try { + char xChar = input.toLowerCase().charAt(0); + int y = Integer.parseInt(input.substring(1)) - 1; + int x = xChar - 'a'; + if (isInputValid(x, y)) { + String result = shot(x, y); + System.out.println(result); + System.out.println("Number of fired shots: " + firedShot); + if (allShipSunk()) { + printBoard(); + System.out.println("All ships have been sunk" + "\nYou won the game\n"); + printBoard(); + game = false; + } + } else { + System.out.println("Invalid input. Please enter a valid coordinate (e.g., A5)."); + } + } catch (NumberFormatException e) { + System.out.println("Invalid input format. Please enter a valid coordinate (e.g., A5)."); + } + } + + // Reveals the positions of hidden ships on the board. + private static void revealHiddenShips() { + for (int i = 0; i < 10; i++) { + for (int j = 0; j < 10; j++) { + if (board[i][j] == HIDDEN_SHIP) { + board[i][j] = REVEALED_SHIP; + } + } + } + } + + // Hides the previously revealed ships on the board. + private static void hideRevealedShips() { + for (int i = 0; i < 10; i++) { + for (int j = 0; j < 10; j++) { + if (board[i][j] == REVEALED_SHIP) { + board[i][j] = HIDDEN_SHIP; + } + } + } + } + + // Initializes the game by setting up the board and randomly placing ships. + private static void initializeGame() { + // Fill board with blanks + for (int i = 0; i < board.length; i++) { + for (int j = 0; j < board[i].length; j++) { + board[i][j] = BLANK; + } + } + + // Place ships randomly + Random random = new Random(); + int i = 0; + int[] ships = { 4, 3, 3, 2, 2, 2, 1, 1, 1, 1 }; + for (int shipSize : ships) { + boolean placed = false; + while (!placed) { + int x = random.nextInt(10); + int y = random.nextInt(10); + boolean direction = random.nextBoolean(); + if (isValidPlacement(x, y, shipSize, direction)) { + shipLength[i] = shipSize; + shipX[i] = x; + shipY[i] = y; + shipDirection[i] = direction; + + i++; + placeShip(x, y, shipSize, direction); + placed = true; + } + } + } + } + + // Validates the placement of a ship on the board. + private static boolean isValidPlacement(int x, int y, int shipSize, boolean direction) { + if (!isWithinBounds(x, y, shipSize, direction)) { + return false; + } + + if (doesOverlap(x, y, shipSize, direction)) { + return false; + } + + return hasSpaceOfWater(x, y, shipSize, direction); + } + + // Checks if the ship placement is within the board boundaries. + private static boolean isWithinBounds(int x, int y, int shipSize, boolean direction) { + if (direction) { + return x >= 0 && x + shipSize <= 10 && y >= 0 && y < 10; + } else { + return y >= 0 && y + shipSize <= 10 && x >= 0 && x < 10; + } + } + + // Checks if the ship placement overlaps with existing ships. + private static boolean doesOverlap(int x, int y, int shipSize, boolean direction) { + for (int i = 0; i < shipSize; i++) { + int row = direction ? y : y + i; + int col = direction ? x + i : x; + + if (board[row][col] != BLANK) { + return true; // Overlaps with existing ship + } + } + return false; + } + + // Ensures that the ship has a space of water around it. + private static boolean hasSpaceOfWater(int x, int y, int shipSize, boolean direction) { + for (int i = 0; i < shipSize; i++) { + int row = direction ? y : y + i; + int col = direction ? x + i : x; + + for (int j = row - 1; j <= row + 1; j++) { + for (int k = col - 1; k <= col + 1; k++) { + if (j >= 0 && j < 10 && k >= 0 && k < 10 && board[j][k] != BLANK) { + return false; // Adjacent cell is not water + } + } + } + } + return true; // Has space of water + } + + // Places a ship on the board at the specified coordinates. + private static void placeShip(int x, int y, int shipSize, boolean direction) { + if (direction) { + for (int i = 0; i < shipSize; i++) { + board[y][x + i] = HIDDEN_SHIP; + } + } else { + for (int i = 0; i < shipSize; i++) { + board[y + i][x] = HIDDEN_SHIP; + } + } + } + + // Gets coordinates input from the user. + private static String getCoordinates() { + Scanner scan = new Scanner(System.in); + return scan.next(); + } + + // Validates the input coordinates. + private static boolean isInputValid(int x, int y) { + return x >= 0 && x < 10 && y >= 0 && y < 10; + } + + // Processes a shot at the specified coordinates and returns the result. + private static String shot(int x, int y) { + switch (board[y][x]) { + case BLANK: + board[y][x] = WATER; + firedShot++; + return "Miss!"; + case WATER: + return "Already shot this field!"; + case HIDDEN_SHIP: + case REVEALED_SHIP: + board[y][x] = SHIP; + firedShot++; + if (isShipSunk(x, y)) { + sinkShip(x, y); + return "You sunk a ship!"; + } else { + return "You hit a ship!"; + } + default: + return "Invalid state!"; + } + } + + // Sinks a ship by marking all its parts as sunk. + private static void sinkShip(int x, int y) { + for (int i = 0; i < shipX.length; i++) { + int startX = shipX[i]; + int startY = shipY[i]; + int length = shipLength[i]; + boolean direction = shipDirection[i]; // true for horizontal, false for vertical + + // Check if the current shot is part of this ship + if (direction) { + // Horizontal ship + if (y == startY && x >= startX && x < startX + length) { + // Mark all parts of the ship as sunk + for (int j = 0; j < length; j++) { + board[startY][startX + j] = SUNK; + } + + for (int j = 0; j < length; j++) { + placeWaterAroundShip(startX + j, startY); + } + return; + } + } else { + // Vertical ship + if (x == startX && y >= startY && y < startY + length) { + // Mark all parts of the ship as sunk + for (int j = 0; j < length; j++) { + board[startY + j][startX] = SUNK; + } + + for (int j = 0; j < length; j++) { + placeWaterAroundShip(startX, startY + j); + } + return; + } + } + } + } + + // Checks if a ship at the specified coordinates is completely sunk. + private static boolean isShipSunk(int x, int y) { + for (int i = 0; i < shipX.length; i++) { + int startX = shipX[i]; + int startY = shipY[i]; + int length = shipLength[i]; + boolean direction = shipDirection[i]; // true for horizontal, false for vertical + + // Check if the current shot is part of this ship + if (direction) { + // Horizontal ship + if (y == startY && x >= startX && x < startX + length) { + // Check all parts of the ship + for (int j = 0; j < length; j++) { + if (board[startY][startX + j] != SHIP && board[startY][startX + j] != SUNK) { + return false; // If any part is not hit, the ship is not sunk + } + } + return true; // All parts are hit, the ship is sunk + } + } else { + // Vertical ship + if (x == startX && y >= startY && y < startY + length) { + // Check all parts of the ship + for (int j = 0; j < length; j++) { + if (board[startY + j][startX] != SHIP && board[startY + j][startX] != SUNK) { + return false; // If any part is not hit, the ship is not sunk + } + } + return true; // All parts are hit, the ship is sunk + } + } + } + return false; // If the shot is not part of any ship (shouldn't happen in a valid game) + } + + // Prints the current state of the board to the console. + private static void printBoard() { + System.out.println(" | A | B | C | D | E | F | G | H | I | J |"); + System.out.println("--------------------------------------------"); + char[] symbols = { ' ', 'O', 'X', 'S', ' ', 'R' }; + + for (int i = 0; i < board.length; i++) { + if (i < 9) { + System.out.print(" " + (i + 1) + " |"); + } else { + System.out.print(" " + (i + 1) + "|"); + } + for (int j = 0; j < board[i].length; j++) { + System.out.print(" " + symbols[board[i][j]] + " |"); + } + System.out.println("\n--------------------------------------------"); + } + } + + // Places water around a sunk ship to mark its surrounding area. + private static void placeWaterAroundShip(int x, int y) { + for (int i = y - 1; i <= y + 1; i++) { + for (int j = x - 1; j <= x + 1; j++) { + if (i >= 0 && i < 10 && j >= 0 && j < 10 && board[i][j] == BLANK) { + board[i][j] = WATER; + } + } + } + } + + // Checks if all ships on the board are sunk. + private static boolean allShipSunk() { + for (int i = 0; i < board.length; i++) { + for (int j = 0; j < board[i].length; j++) { + if (board[i][j] == HIDDEN_SHIP || board[i][j] == REVEALED_SHIP) { + return false; // Found a ship that is not sunk + } + } + } + return true; // All ships are sunk + } +} diff --git a/Code/battleShip/src/test.class b/Code/battleShip/src/test.class new file mode 100644 index 0000000..98cb99a Binary files /dev/null and b/Code/battleShip/src/test.class differ diff --git a/Code/battleShip/src/test.java b/Code/battleShip/src/test.java new file mode 100644 index 0000000..7bcb480 --- /dev/null +++ b/Code/battleShip/src/test.java @@ -0,0 +1,357 @@ +import java.util.Random; +import java.util.Scanner; + +public class test { + // Spielfeld-Zeichen + public static final int LEER = 0; // ' ' + public static final int WASSER = 1; // 'O' + public static final int SCHIFF = 2; // 'X' + public static final int VERSENKT = 3; // 'S' + public static final int VERSTECKT = 4; // ' ' + public static final int ENTHÜLLT = 5; // 'R' + + // spielfeld[vertikal --> y][horizontal --> x] + public static int[][] spielfeld = new int[10][10]; + + // Array, in dem die Schiffe gespeichert sind + private static int[] schiffX = new int[10]; + private static int[] schiffY = new int[10]; + private static boolean[] schiffRichtung = new boolean[10]; + private static int[] schiffLänge = new int[10]; + + // Anzahl der abgefeuerten Schüsse + public static int abgefeuerteSchüsse = 0; + public static boolean spielLäuft = true; + + public static void main(String[] args) { + boolean sindSchiffeEnthüllt = false; + // Regeln erklären + spielInitialisieren(); + do { + spielfeldZeigen(); + System.out.println( + "Wohin möchtest du schießen? (z.B., A5 oder ? für einen Tipp oder -1 zum Beenden des Spiels)"); + String eingabe = koordinateEingeben(); + + switch (eingabe) { + case "-1": + spielLäuft = false; + break; + case "?": + versteckteSchiffeZeigen(); + sindSchiffeEnthüllt = true; + break; + default: + // Die Zeilen 47-49 sollten beim Debuggen deaktiviert werden, um es einfacher zu + // machen + if (sindSchiffeEnthüllt) { + enthüllteSchiffeVerstecken(); + } + schussVerarbeiten(eingabe); + break; + } + } while (spielLäuft); + } + + // Verarbeitet die Schusseingabe des Spielers, validiert sie und führt den + // Schuss aus. + private static void schussVerarbeiten(String eingabe) { + try { + char xChar = eingabe.toLowerCase().charAt(0); + int y = Integer.parseInt(eingabe.substring(1)) - 1; + int x = xChar - 'a'; + if (eingabeIstGültig(x, y)) { + String ergebnis = schießen(x, y); + System.out.println(ergebnis); + System.out.println("Anzahl der abgefeuerten Schüsse: " + abgefeuerteSchüsse); + if (alleSchiffeVersenkt()) { + spielfeldZeigen(); + System.out.println("Alle Schiffe wurden versenkt\nDu hast das Spiel gewonnen\n"); + spielfeldZeigen(); + spielLäuft = false; + } + } else { + System.out.println("Ungültige Eingabe. Bitte gib eine gültige Koordinate ein (z.B., A5)."); + } + } catch (NumberFormatException e) { + System.out.println("Ungültiges Eingabeformat. Bitte gib eine gültige Koordinate ein (z.B., A5)."); + } + } + + // Zeigt die Positionen der versteckten Schiffe auf dem Spielfeld an. + private static void versteckteSchiffeZeigen() { + for (int i = 0; i < 10; i++) { + for (int j = 0; j < 10; j++) { + if (spielfeld[i][j] == VERSTECKT) { + spielfeld[i][j] = ENTHÜLLT; + } + } + } + } + + // Versteckt die zuvor enthüllten Schiffe auf dem Spielfeld. + private static void enthüllteSchiffeVerstecken() { + for (int i = 0; i < 10; i++) { + for (int j = 0; j < 10; j++) { + if (spielfeld[i][j] == ENTHÜLLT) { + spielfeld[i][j] = VERSTECKT; + } + } + } + } + + // Initialisiert das Spiel, indem das Spielfeld eingerichtet und Schiffe + // zufällig platziert werden. + private static void spielInitialisieren() { + // Spielfeld mit leeren Feldern füllen + for (int i = 0; i < spielfeld.length; i++) { + for (int j = 0; j < spielfeld[i].length; j++) { + spielfeld[i][j] = LEER; + } + } + + // Schiffe zufällig platzieren + Random zufall = new Random(); + int i = 0; + int[] schiffe = { 4, 3, 3, 2, 2, 2, 1, 1, 1, 1 }; + for (int schiffGröße : schiffe) { + boolean platziert = false; + while (!platziert) { + int x = zufall.nextInt(10); + int y = zufall.nextInt(10); + boolean richtung = zufall.nextBoolean(); + if (platzierungIstGültig(x, y, schiffGröße, richtung)) { + schiffLänge[i] = schiffGröße; + schiffX[i] = x; + schiffY[i] = y; + schiffRichtung[i] = richtung; + + i++; + schiffPlatzieren(x, y, schiffGröße, richtung); + platziert = true; + } + } + } + } + + // Validiert die Platzierung eines Schiffs auf dem Spielfeld. + private static boolean platzierungIstGültig(int x, int y, int schiffGröße, boolean richtung) { + if (!innerhalbGrenzen(x, y, schiffGröße, richtung)) { + return false; + } + + if (überschneidung(x, y, schiffGröße, richtung)) { + return false; + } + + return hatWasserPlatz(x, y, schiffGröße, richtung); + } + + // Überprüft, ob die Schiffplatzierung innerhalb der Spielfeldgrenzen liegt. + private static boolean innerhalbGrenzen(int x, int y, int schiffGröße, boolean richtung) { + if (richtung) { + return x >= 0 && x + schiffGröße <= 10 && y >= 0 && y < 10; + } else { + return y >= 0 && y + schiffGröße <= 10 && x >= 0 && x < 10; + } + } + + // Überprüft, ob sich die Schiffplatzierung mit vorhandenen Schiffen + // überschneidet. + private static boolean überschneidung(int x, int y, int schiffGröße, boolean richtung) { + for (int i = 0; i < schiffGröße; i++) { + int reihe = richtung ? y : y + i; + int spalte = richtung ? x + i : x; + + if (spielfeld[reihe][spalte] != LEER) { + return true; // Überschneidet sich mit einem vorhandenen Schiff + } + } + return false; + } + + // Stellt sicher, dass das Schiff einen Platz mit Wasser um sich herum hat. + private static boolean hatWasserPlatz(int x, int y, int schiffGröße, boolean richtung) { + for (int i = 0; i < schiffGröße; i++) { + int reihe = richtung ? y : y + i; + int spalte = richtung ? x + i : x; + + for (int j = reihe - 1; j <= reihe + 1; j++) { + for (int k = spalte - 1; k <= spalte + 1; k++) { + if (j >= 0 && j < 10 && k >= 0 && k < 10 && spielfeld[j][k] != LEER) { + return false; // Benachbartes Feld ist kein Wasser + } + } + } + } + return true; // Hat Platz mit Wasser + } + + // Platziert ein Schiff auf dem Spielfeld an den angegebenen Koordinaten. + private static void schiffPlatzieren(int x, int y, int schiffGröße, boolean richtung) { + if (richtung) { + for (int i = 0; i < schiffGröße; i++) { + spielfeld[y][x + i] = VERSTECKT; + } + } else { + for (int i = 0; i < schiffGröße; i++) { + spielfeld[y + i][x] = VERSTECKT; + } + } + } + + // Holt die Koordinateneingabe vom Benutzer. + private static String koordinateEingeben() { + Scanner scan = new Scanner(System.in); + return scan.next(); + } + + // Überprüft, ob die Eingabekoordinaten gültig sind. + private static boolean eingabeIstGültig(int x, int y) { + return x >= 0 && x < 10 && y >= 0 && y < 10; + } + + // Verarbeitet einen Schuss auf die angegebenen Koordinaten und gibt das + // Ergebnis zurück. + private static String schießen(int x, int y) { + switch (spielfeld[y][x]) { + case LEER: + spielfeld[y][x] = WASSER; + abgefeuerteSchüsse++; + return "Daneben!"; + case WASSER: + return "Dieses Feld wurde bereits beschossen!"; + case VERSTECKT: + case ENTHÜLLT: + spielfeld[y][x] = SCHIFF; + abgefeuerteSchüsse++; + if (schiffVersenkt(x, y)) { + schiffVersenken(x, y); + return "Du hast ein Schiff versenkt!"; + } else { + return "Du hast ein Schiff getroffen!"; + } + default: + return "Ungültiger Zustand!"; + } + } + + // Versenkt ein Schiff, indem alle seine Teile als versenkt markiert werden. + private static void schiffVersenken(int x, int y) { + for (int i = 0; i < schiffX.length; i++) { + int startX = schiffX[i]; + int startY = schiffY[i]; + int länge = schiffLänge[i]; + boolean richtung = schiffRichtung[i]; // true für horizontal, false für vertikal + + // Überprüfen, ob der aktuelle Schuss Teil dieses Schiffes ist + if (richtung) { + // Horizontales Schiff + if (y == startY && x >= startX && x < startX + länge) { + // Markiere alle Teile des Schiffes als versenkt + for (int j = 0; j < länge; j++) { + spielfeld[startY][startX + j] = VERSENKT; + } + + for (int j = 0; j < länge; j++) { + wasserUmSchiffPlatzieren(startX + j, startY); + } + return; + } + } else { + // Vertikales Schiff + if (x == startX && y >= startY && y < startY + länge) { + // Markiere alle Teile des Schiffes als versenkt + for (int j = 0; j < länge; j++) { + spielfeld[startY + j][startX] = VERSENKT; + } + + for (int j = 0; j < länge; j++) { + wasserUmSchiffPlatzieren(startX, startY + j); + } + return; + } + } + } + } + + // Überprüft, ob ein Schiff an den angegebenen Koordinaten vollständig versenkt + // ist. + private static boolean schiffVersenkt(int x, int y) { + for (int i = 0; i < schiffX.length; i++) { + int startX = schiffX[i]; + int startY = schiffY[i]; + int länge = schiffLänge[i]; + boolean richtung = schiffRichtung[i]; // true für horizontal, false für vertikal + + // Überprüfen, ob der aktuelle Schuss Teil dieses Schiffes ist + if (richtung) { + // Horizontales Schiff + if (y == startY && x >= startX && x < startX + länge) { + // Überprüfen alle Teile des Schiffes + for (int j = 0; j < länge; j++) { + if (spielfeld[startY][startX + j] != SCHIFF && spielfeld[startY][startX + j] != VERSENKT) { + return false; // Wenn ein Teil nicht getroffen ist, ist das Schiff nicht versenkt + } + } + return true; // Alle Teile sind getroffen, das Schiff ist versenkt + } + } else { + // Vertikales Schiff + if (x == startX && y >= startY && y < startY + länge) { + // Überprüfen alle Teile des Schiffes + for (int j = 0; j < länge; j++) { + if (spielfeld[startY + j][startX] != SCHIFF && spielfeld[startY + j][startX] != VERSENKT) { + return false; // Wenn ein Teil nicht getroffen ist, ist das Schiff nicht versenkt + } + } + return true; // Alle Teile sind getroffen, das Schiff ist versenkt + } + } + } + return false; // Wenn der Schuss kein Teil eines Schiffes ist (sollte in einem gültigen Spiel + // nicht passieren) + } + + // Zeigt den aktuellen Zustand des Spielfelds auf der Konsole an. + private static void spielfeldZeigen() { + System.out.println(" | A | B | C | D | E | F | G | H | I | J |"); + System.out.println("--------------------------------------------"); + char[] symbole = { ' ', 'O', 'X', 'S', ' ', 'R' }; + + for (int i = 0; i < spielfeld.length; i++) { + if (i < 9) { + System.out.print(" " + (i + 1) + " |"); + } else { + System.out.print(" " + (i + 1) + "|"); + } + for (int j = 0; j < spielfeld[i].length; j++) { + System.out.print(" " + symbole[spielfeld[i][j]] + " |"); + } + System.out.println("\n--------------------------------------------"); + } + } + + // Platziert Wasser um ein versenktes Schiff, um dessen Umgebung zu markieren. + private static void wasserUmSchiffPlatzieren(int x, int y) { + for (int i = y - 1; i <= y + 1; i++) { + for (int j = x - 1; j <= x + 1; j++) { + if (i >= 0 && i < 10 && j >= 0 && j < 10 && spielfeld[i][j] == LEER) { + spielfeld[i][j] = WASSER; + } + } + } + } + + // Überprüft, ob alle Schiffe auf dem Spielfeld versenkt sind. + private static boolean alleSchiffeVersenkt() { + for (int i = 0; i < spielfeld.length; i++) { + for (int j = 0; j < spielfeld[i].length; j++) { + if (spielfeld[i][j] == VERSTECKT || spielfeld[i][j] == ENTHÜLLT) { + return false; // Ein Schiff wurde gefunden, das nicht versenkt ist + } + } + } + return true; // Alle Schiffe sind versenkt + } +} diff --git a/Code/bookAufgabe3/.vscode/settings.json b/Code/bookAufgabe3/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/bookAufgabe3/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/bookAufgabe3/README.md b/Code/bookAufgabe3/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/bookAufgabe3/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/bookAufgabe3/bin/App.class b/Code/bookAufgabe3/bin/App.class new file mode 100644 index 0000000..0ee6cf8 Binary files /dev/null and b/Code/bookAufgabe3/bin/App.class differ diff --git a/Code/bookAufgabe3/src/App.java b/Code/bookAufgabe3/src/App.java new file mode 100644 index 0000000..0f6911f --- /dev/null +++ b/Code/bookAufgabe3/src/App.java @@ -0,0 +1,31 @@ + +// împort java extansions +import java.util.Scanner; + +public class App { + public static void main(String[] args) { + Scanner scan = new Scanner(System.in); + + System.out.println("Give me a number please:"); + int number = scan.nextInt(); + int math = 0; + int numberOfDigits = 0; + int sum = 0; + + // Number of digits + for (int tempNumber = number; tempNumber > 0; tempNumber = tempNumber / 10) { + numberOfDigits++; + } + + // math the digits-diffrence + for (int tempNumber = number; tempNumber > 0; tempNumber = tempNumber / 10) { + math = tempNumber % 10; + sum += math; + } + + System.out.println("Anzahl der Ziffern: " + numberOfDigits); + System.out.println("Ziffernsumme: " + sum); + + scan.close(); + } +} diff --git a/Code/bookTaskTwo/.vscode/settings.json b/Code/bookTaskTwo/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/bookTaskTwo/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/bookTaskTwo/README.md b/Code/bookTaskTwo/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/bookTaskTwo/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/bookTaskTwo/bin/App.class b/Code/bookTaskTwo/bin/App.class new file mode 100644 index 0000000..7e1997a Binary files /dev/null and b/Code/bookTaskTwo/bin/App.class differ diff --git a/Code/bookTaskTwo/src/App.java b/Code/bookTaskTwo/src/App.java new file mode 100644 index 0000000..e6066e1 --- /dev/null +++ b/Code/bookTaskTwo/src/App.java @@ -0,0 +1,16 @@ +import java.util.Scanner; + +public class App { + public static void main(String[] args) { + Scanner scan = new Scanner(System.in); + System.out.println("Please enter a postive number"); + int number = scan.nextInt(); + int numberDigits = 0; + + for (int digits = 0; number > 0; digits++) { + number = number / 10; + numberDigits++; + } + System.out.println("Your number contains: " + numberDigits + " digit(s)."); + } +} diff --git a/Code/case/.vscode/settings.json b/Code/case/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/case/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/case/README.md b/Code/case/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/case/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/case/bin/App.class b/Code/case/bin/App.class new file mode 100644 index 0000000..1743ddd Binary files /dev/null and b/Code/case/bin/App.class differ diff --git a/Code/case/src/App.java b/Code/case/src/App.java new file mode 100644 index 0000000..d4ad5fd --- /dev/null +++ b/Code/case/src/App.java @@ -0,0 +1,41 @@ +import java.util.Scanner; + +public class App { + static Scanner scan = new Scanner(System.in); + + public static void main(String[] args) { + System.out.println( + "Arbeitstag-Nummer (1=Montag, 2=Dienstag, 3=Mittwoch, 4=Donnerstag, 5=Freitag)"); + int arbeitstagNummer = scan.nextInt(); + scan.close(); + String tag = "leer"; + + switch (arbeitstagNummer) { + case 1: + tag = "Montag"; + break; + case 2: + tag = "Dienstag"; + break; + case 3: + tag = "Mittwoch"; + break; + case 4: + tag = "Donnerstag"; + break; + case 5: + tag = "Freitag"; + break; + + default: + System.out.println("error"); + } + + // Checking for errors + if (tag.equals("leer")) { + System.out.println("please don't do that again"); + } else { + System.out.println(tag); + } + } +} \ No newline at end of file diff --git a/Code/cute/.vscode/settings.json b/Code/cute/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/cute/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/cute/README.md b/Code/cute/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/cute/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/cute/bin/App.class b/Code/cute/bin/App.class new file mode 100644 index 0000000..fc5a1c6 Binary files /dev/null and b/Code/cute/bin/App.class differ diff --git a/Code/cute/src/App.java b/Code/cute/src/App.java new file mode 100644 index 0000000..98e8a99 --- /dev/null +++ b/Code/cute/src/App.java @@ -0,0 +1,6 @@ +public class App { + public static void main(String[] args) throws Exception { + System.out.println("Is Maria cuter than me?"); + System.out.println("yes ofc"); + } +} diff --git a/Code/debugging/.vscode/settings.json b/Code/debugging/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/debugging/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/debugging/README.md b/Code/debugging/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/debugging/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/debugging/bin/App.class b/Code/debugging/bin/App.class new file mode 100644 index 0000000..bf9cb9b Binary files /dev/null and b/Code/debugging/bin/App.class differ diff --git a/Code/debugging/src/App.java b/Code/debugging/src/App.java new file mode 100644 index 0000000..d78ee65 --- /dev/null +++ b/Code/debugging/src/App.java @@ -0,0 +1,38 @@ +public class App { + public static void main(String[] args) { + double[] temperaturMesswerte = { 0.1, 4.3, 32.9, 329, 18.5, 123.4, 1.8, -7.3, 0.0, 3.7, -2.1, -455.8, 31.1, + 38.1 }; + double minPlausiblerWert = -60.0; + double maxPlausiblerWert = 60.0; + + System.out.println("Minimaler Wert: " + minValue(temperaturMesswerte, minPlausiblerWert, maxPlausiblerWert)); + double maximalerWert = maxValue(temperaturMesswerte, minPlausiblerWert, maxPlausiblerWert); + System.out.println("Maximaler Wert: " + maximalerWert); + } + + /* + * minValue + */ + public static double minValue(double[] messwerte, double minPlausibel, double maxPlausibel) { + double minValue = Double.MAX_VALUE; + for (int i = 0; i < messwerte.length; i++) { + if (minValue > messwerte[i] && messwerte[i] >= minPlausibel && messwerte[i] <= maxPlausibel) { + minValue = messwerte[i]; + } + } + return minValue; + } + + /* + * maxValue + */ + public static double maxValue(double[] messwerte, double minPlausibel, double maxPlausibel) { + double maxValue = Double.MIN_VALUE; + for (int i = 0; i < messwerte.length; i++) { + if (maxValue < messwerte[i] && messwerte[i] >= minPlausibel && messwerte[i] <= maxPlausibel) { + maxValue = messwerte[i]; + } + } + return maxValue; + } +} \ No newline at end of file diff --git a/Code/debugging02/.vscode/settings.json b/Code/debugging02/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/debugging02/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/debugging02/README.md b/Code/debugging02/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/debugging02/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/debugging02/bin/App.class b/Code/debugging02/bin/App.class new file mode 100644 index 0000000..1995fcc Binary files /dev/null and b/Code/debugging02/bin/App.class differ diff --git a/Code/debugging02/src/App.java b/Code/debugging02/src/App.java new file mode 100644 index 0000000..ee4d492 --- /dev/null +++ b/Code/debugging02/src/App.java @@ -0,0 +1,45 @@ +import java.util.Scanner; + +public class App { + + public static void main(String[] args) { + Scanner scan = new Scanner(System.in); + int[] varZahl = new int[10]; + + //Erfassen der Daten + while (true) { + System.out.println("Bitte eine Zahl zwischen 0 und 9 (99 zum beenden)"); + int gluecksZahl = scan.nextInt(); + if (gluecksZahl < 0 || gluecksZahl > 9) { + break; + } + varZahl[gluecksZahl]++; + } + + //Ausgabe der Statistik + for (int i = 0; i <= 9; i++) { + System.out.println(i + " :" + varZahl[i]); + } + + //Ausgabe der maximal gewählten Zahl + System.out.println("Meistgewählte Glückszahl: " + meistGewaehlteGlueckszahl(varZahl)); + + scan.close(); + } + + /* + * meistGewaehlteGlueckszahl + */ + public static int meistGewaehlteGlueckszahl(int[] gluecksZahlen) { + int meistGewaehlteZahl = -1; + int anzahlMax = Integer.MIN_VALUE; + for (int i = 0; i < gluecksZahlen.length; i++) { + if (anzahlMax < gluecksZahlen[i]) { + anzahlMax = gluecksZahlen[i]; + meistGewaehlteZahl = i; + } + } + + return meistGewaehlteZahl; + } +} \ No newline at end of file diff --git a/Code/dnd dice/.vscode/settings.json b/Code/dnd dice/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/dnd dice/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/dnd dice/README.md b/Code/dnd dice/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/dnd dice/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/dnd dice/bin/App.class b/Code/dnd dice/bin/App.class new file mode 100644 index 0000000..1781e34 Binary files /dev/null and b/Code/dnd dice/bin/App.class differ diff --git a/Code/dnd dice/src/App.class b/Code/dnd dice/src/App.class new file mode 100644 index 0000000..f0b9ab1 Binary files /dev/null and b/Code/dnd dice/src/App.class differ diff --git a/Code/dnd dice/src/App.java b/Code/dnd dice/src/App.java new file mode 100644 index 0000000..5f2e648 --- /dev/null +++ b/Code/dnd dice/src/App.java @@ -0,0 +1,51 @@ +import java.util.Arrays; + +public class App { + public static void main(String[] args) { + int numberOfRolls = 1000; + int numberOfDice = 4; + + int[] results = new int[numberOfRolls]; + + // Simulate rolling 4d6 and dropping the lowest value for 1000 times + for (int i = 0; i < numberOfRolls; i++) { + results[i] = rollAndDropLowest(numberOfDice); + } + + // Sort the results for calculating median + Arrays.sort(results); + + // Calculate and print lowest, highest, average, and median values + int lowest = results[0]; + int highest = results[numberOfRolls - 1]; + double average = Arrays.stream(results).average().orElse(0); + + int median; + if (numberOfRolls % 2 == 0) { + median = (results[numberOfRolls / 2 - 1] + results[numberOfRolls / 2]) / 2; + } else { + median = results[numberOfRolls / 2]; + } + + System.out.println("Lowest: " + lowest); + System.out.println("Highest: " + highest); + System.out.println("Average: " + average); + System.out.println("Median: " + median); + } + + // Simulate rolling n dice and dropping the lowest value + private static int rollAndDropLowest(int n) { + int[] rolls = new int[n]; + + // Roll the dice + for (int i = 0; i < n; i++) { + rolls[i] = (int) (Math.random() * 6) + 1; + } + + // Sort the rolls and drop the lowest value + Arrays.sort(rolls); + int sum = rolls[1] + rolls[2] + rolls[3]; + + return sum; + } +} diff --git a/Code/forDebugging/.vscode/settings.json b/Code/forDebugging/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/forDebugging/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/forDebugging/README.md b/Code/forDebugging/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/forDebugging/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/forDebugging/bin/App.class b/Code/forDebugging/bin/App.class new file mode 100644 index 0000000..9172a7c Binary files /dev/null and b/Code/forDebugging/bin/App.class differ diff --git a/Code/forDebugging/src/App.java b/Code/forDebugging/src/App.java new file mode 100644 index 0000000..f35fd39 --- /dev/null +++ b/Code/forDebugging/src/App.java @@ -0,0 +1,19 @@ +public class App { + + public static void main(String[] args) { + int max = 42; + for (int zahl1 = 1; zahl1 <= max; zahl1++) { + for (int zahl2 = zahl1 + 1; zahl2 <= max; zahl2++) { + for (int zahl3 = zahl2 + 1; zahl3 <= max; zahl3++) { + for (int zahl4 = zahl3 + 1; zahl4 <= max; zahl4++) { + for (int zahl5 = zahl4 + 1; zahl5 <= max; zahl5++) { + for (int zahl6 = zahl5 + 1; zahl6 <= max; zahl6++) { + // Durchlauf + } + } + } + } + } + } + } +} diff --git a/Code/forIterration/.vscode/settings.json b/Code/forIterration/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/forIterration/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/forIterration/README.md b/Code/forIterration/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/forIterration/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/forIterration/bin/App.class b/Code/forIterration/bin/App.class new file mode 100644 index 0000000..132a231 Binary files /dev/null and b/Code/forIterration/bin/App.class differ diff --git a/Code/forIterration/src/App.java b/Code/forIterration/src/App.java new file mode 100644 index 0000000..a25275b --- /dev/null +++ b/Code/forIterration/src/App.java @@ -0,0 +1,38 @@ +public class App { + public static void main(String[] args) throws Exception { + int minute = 0; + boolean under10 = false; + + for (int hour = 0; hour <= 23; minute++) { + + if (minute == 60) { + minute = 0; + hour++; + } + + switch (hour) { + case 1, 2, 3, 4, 5, 6, 7, 8, 9: + under10 = true; + break; + + default: + break; + } + + if (under10) { + if (minute < 10) { + System.out.println("0" + hour + ":" + "0" + minute); + } else { + System.out.println(hour + ":" + minute); + } + } else { + if (minute < 10) { + System.out.println(hour + ":" + "0" + minute); + } else { + System.out.println(hour + ":" + minute); + } + } + } + System.out.println("End of Code"); + } +} diff --git a/Code/gambling/.vscode/settings.json b/Code/gambling/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/gambling/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/gambling/README.md b/Code/gambling/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/gambling/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/gambling/bin/App.class b/Code/gambling/bin/App.class new file mode 100644 index 0000000..22c5ba3 Binary files /dev/null and b/Code/gambling/bin/App.class differ diff --git a/Code/gambling/src/App.class b/Code/gambling/src/App.class new file mode 100644 index 0000000..c1588b0 Binary files /dev/null and b/Code/gambling/src/App.class differ diff --git a/Code/gambling/src/App.java b/Code/gambling/src/App.java new file mode 100644 index 0000000..c5d740d --- /dev/null +++ b/Code/gambling/src/App.java @@ -0,0 +1,77 @@ +import java.util.Random; +import java.util.Scanner; + +public class App { + public static int Budget = 1000; + + public static void main(String[] args) { + while (true) { + System.out.println("1. Coinflip, 2. Blackjack, 3. Roulette"); + int input = getInput(); + switch (input) { + case 1: + playCoinflip(); + break; + case 2: + playBlackjack(); + break; + case 3: + playRoulette(); + break; + default: + System.out.println("Error: enter a valid code"); + break; + } + } + } + + public static int getInput() { + Scanner scan = new Scanner(System.in); + System.out.print("Enter your choice: "); + return scan.nextInt(); + } + + public static void playCoinflip() { + Scanner scan = new Scanner(System.in); + Random random = new Random(); + while (true) { + System.out.print("Enter your bet: "); + int bet = scan.nextInt(); + if (bet > Budget) { + System.out.println("You don't have enough money."); + return; + } + + System.out.print("Enter 1 for heads or 2 for tails: "); + int choice = scan.nextInt(); + int result = random.nextInt(2) + 1; + + if (choice == result) { + Budget += bet; + System.out.println("You won!"); + } else { + Budget -= bet; + System.out.println("You lost."); + } + printBudget(); + } + } + + public static void playBlackjack() { + // Placeholder for Blackjack game logic + System.out.println("Blackjack game coming soon..."); + // Update budget here based on game result + printBudget(); + } + + public static void playRoulette() { + // Placeholder for Roulette game logic + System.out.println("Roulette game coming soon..."); + // Update budget here based on game result + printBudget(); + } + + public static void printBudget() { + System.out.println("Current Budget: $" + Budget); + } +} diff --git a/Code/gaySex/.vscode/settings.json b/Code/gaySex/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/gaySex/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/gaySex/README.md b/Code/gaySex/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/gaySex/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/gaySex/bin/App.class b/Code/gaySex/bin/App.class new file mode 100644 index 0000000..876a5c4 Binary files /dev/null and b/Code/gaySex/bin/App.class differ diff --git a/Code/gaySex/src/App.java b/Code/gaySex/src/App.java new file mode 100644 index 0000000..bbd0093 --- /dev/null +++ b/Code/gaySex/src/App.java @@ -0,0 +1,13 @@ +public class App { + public static void main(String[] args) { + int a = 22; + int b = 13; + + int y = a; + + while (y > b) { + System.out.println("F: " + y); + y--; + } + } +} diff --git a/Code/genericTask/.vscode/settings.json b/Code/genericTask/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/genericTask/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/genericTask/README.md b/Code/genericTask/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/genericTask/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/genericTask/bin/App.class b/Code/genericTask/bin/App.class new file mode 100644 index 0000000..de60756 Binary files /dev/null and b/Code/genericTask/bin/App.class differ diff --git a/Code/genericTask/src/App.java b/Code/genericTask/src/App.java new file mode 100644 index 0000000..e4f0668 --- /dev/null +++ b/Code/genericTask/src/App.java @@ -0,0 +1,38 @@ +public class App { + + public static void main(String[] args) { + // Aufgabe 1 + String meinText = "Ich bin ein völlig zufälliger und neutraler Text."; + System.out.println(textLeft(meinText, 3)); // Konsolenausgabe: Ich + + // Aufgabe 2 + System.out.println(textRight(meinText, 5)); // Konsolenausgabe: Text. + + // Aufgabe 3 + String buchstaben = "9"; + int positionImAbc = zeichenPositionImAbc(buchstaben) + 1; + if (positionImAbc == 0) { + System.out.println(buchstaben + " is not in the alphabet"); + } else + System.out.println(buchstaben + " ist der " + positionImAbc + ". Buchstaben im Abc"); + } + + // Aufgabe 1 + public static String textLeft(String text, int anzahlZeichenVonLinks) { + return text.substring(0, Math.min(anzahlZeichenVonLinks, text.length())); + } + + // Aufgabe 2 + public static String textRight(String text, int anzahlZeichenVonRechts) { + return text.substring(Math.max(text.length() - anzahlZeichenVonRechts, 0)); + } + + // Aufgabe 3 + public static int zeichenPositionImAbc(String zeichen) { + if (zeichen.length() != 1) { + return -1; + } else { + return Character.toUpperCase(zeichen.charAt(0)) - 'A'; + } + } +} diff --git a/Code/getNachname/.vscode/settings.json b/Code/getNachname/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/getNachname/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/getNachname/README.md b/Code/getNachname/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/getNachname/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/getNachname/bin/App.class b/Code/getNachname/bin/App.class new file mode 100644 index 0000000..48a0f53 Binary files /dev/null and b/Code/getNachname/bin/App.class differ diff --git a/Code/getNachname/src/App.java b/Code/getNachname/src/App.java new file mode 100644 index 0000000..084d051 --- /dev/null +++ b/Code/getNachname/src/App.java @@ -0,0 +1,44 @@ +import java.util.Scanner; + +public class App { + static Scanner scan = new Scanner(System.in); + + public static void main(String[] args) throws Exception { + String[] name = { "Emma", "Liam", "Sophia", "Noah", "Olivia", "William", "Ava", "James", "Isabella", + "Lucas" }; + String[] lastname = { "Müller", "Schmidt", "Schneider", "Fischer", "Weber", "Meyer", "Wagner", "Becker", + "Schulz", "Hoffmann" }; + + for (boolean search = true; search;) { + + String searchName = getInput(); + if (searchName.equals("")) { + search = false; + break; + } else { + int foundName = getLastname(name, searchName, lastname); + if (foundName == -1) { + System.out.println("Name not found please create a new entry"); + } else + System.out.println(name[foundName] + " " + lastname[foundName]); + } + } + } + + public static String getInput() { + System.out.println("Please enter the name of the person your searching :)"); + System.out.println("to stop searching press enter without input"); + return scan.nextLine(); + } + + public static int getLastname(String[] name, String searchName, String[] lastname) { + int i; + + for (i = 0; i < name.length; i++) { + if (searchName.equalsIgnoreCase(name[i])) { + return i; + } + } + return -1; + } +} diff --git a/Code/guessing_game/game01/.vscode/settings.json b/Code/guessing_game/game01/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/guessing_game/game01/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/guessing_game/game01/README.md b/Code/guessing_game/game01/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/guessing_game/game01/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/guessing_game/game01/bin/App.class b/Code/guessing_game/game01/bin/App.class new file mode 100644 index 0000000..672ed83 Binary files /dev/null and b/Code/guessing_game/game01/bin/App.class differ diff --git a/Code/guessing_game/game01/src/App.java b/Code/guessing_game/game01/src/App.java new file mode 100644 index 0000000..2940b5c --- /dev/null +++ b/Code/guessing_game/game01/src/App.java @@ -0,0 +1,42 @@ +import java.util.Random; +import java.util.Scanner; + +public class App { + static Scanner scan = new Scanner(System.in); + static Random random = new Random(); + + public static void main(String[] args) { + int numberOfTries = 0; + int maxNumber = 100; + int randomNumber = random.nextInt(maxNumber) + 1; + int userinput = 0; + + System.out.println("Number for the dev to check if the games is working: " + randomNumber); + + System.out.println("Welcome to the Number Guessing Game!"); + System.out.println("I have selected a random number between " + 0 + " and " + maxNumber + "."); + System.out.println("Try to guess the number."); + + while (true) { + numberOfTries++; + System.out.println(numberOfTries + ". Try"); + userinput = scan.nextInt(); + + if (randomNumber > userinput) { + System.out.println("Lmao no the number is bigger"); + } else if (randomNumber == userinput) { + System.out.println("You got the right number my brother"); + System.out.println("You only needed " + numberOfTries + " tries"); + break; + } else { + System.out.println("No the number is smaller"); + } + } + + if (numberOfTries == 1) { + System.out.println("No offense but are you sure you didn't cheat?"); + } + scan.close(); + } + +} diff --git a/Code/guessing_game/game1/.vscode/settings.json b/Code/guessing_game/game1/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/guessing_game/game1/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/guessing_game/game1/README.md b/Code/guessing_game/game1/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/guessing_game/game1/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/guessing_game/game1/bin/App.class b/Code/guessing_game/game1/bin/App.class new file mode 100644 index 0000000..c6ab7d9 Binary files /dev/null and b/Code/guessing_game/game1/bin/App.class differ diff --git a/Code/guessing_game/game1/src/App.java b/Code/guessing_game/game1/src/App.java new file mode 100644 index 0000000..6ee6c31 --- /dev/null +++ b/Code/guessing_game/game1/src/App.java @@ -0,0 +1,43 @@ +import java.util.Random; +import java.util.Scanner; + +public class App { + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + Random random = new Random(); + + int minRange = -1000; + int maxRange = 1000; + + int randomNumber = random.nextInt(maxRange - minRange + 1) + minRange; + int numberOfTries = 0; + int inputNumber; + + // System.out.println("Number for the dev to check if the games is working: " + + // randomNumber); + + System.out.println("Welcome to the Number Guessing Game!"); + System.out.println("I have selected a random number between " + minRange + " and " + maxRange + "."); + System.out.println("Try to guess the number."); + + do { + System.out.print("Enter your guess: "); + inputNumber = scanner.nextInt(); + numberOfTries++; + + if (inputNumber < randomNumber) { + System.out.println("The number is higher. Try again. (" + numberOfTries + " Try)"); + } else if (inputNumber > randomNumber) { + System.out.println("The number is lower. Try again. (" + numberOfTries + " Try)"); + } else { + System.out.println( + "Congratulations! You guessed the number " + randomNumber + " in " + numberOfTries + " tries."); + } + } while (inputNumber != randomNumber); + if (numberOfTries == 1) { + System.out.println("No offense but are you sure you didn't cheat?"); + } + + scanner.close(); + } +} diff --git a/Code/hackingYourOwnPassword/.vscode/settings.json b/Code/hackingYourOwnPassword/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/hackingYourOwnPassword/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/hackingYourOwnPassword/README.md b/Code/hackingYourOwnPassword/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/hackingYourOwnPassword/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/hackingYourOwnPassword/bin/App.class b/Code/hackingYourOwnPassword/bin/App.class new file mode 100644 index 0000000..56efa95 Binary files /dev/null and b/Code/hackingYourOwnPassword/bin/App.class differ diff --git a/Code/hackingYourOwnPassword/src/App.java b/Code/hackingYourOwnPassword/src/App.java new file mode 100644 index 0000000..a120b97 --- /dev/null +++ b/Code/hackingYourOwnPassword/src/App.java @@ -0,0 +1,38 @@ +import java.util.Scanner; + +public class App { + static Scanner scan = new Scanner(System.in); + + public static void main(String[] args) throws Exception { + String end = "I am stupid"; + String secretPassword = "geheim"; + String userInput = ""; + int numberOfTriesRemaining = 10; + boolean rightPassword = false; + + do { + System.out.println("Please enter your password. You have " + numberOfTriesRemaining + " tries remaining" + + " alternetively write the following text to end the procees: " + end); + userInput = scan.nextLine(); + numberOfTriesRemaining--; + + if (userInput.equalsIgnoreCase(end)) { + break; + } + + if (userInput.equals(secretPassword)) { + rightPassword = true; + } + + } while (!rightPassword && numberOfTriesRemaining >= 0); + + if (rightPassword) { + System.out.println("Logged in into super extreme secret account!"); + } else if (userInput.equalsIgnoreCase(end)) { + System.out.println("Login cancelled"); + } else { + System.out.println("You're super secret account has been permanently looked, please do not call IT"); + } + + } +} diff --git a/Code/heeeeeeeloWorld/.vscode/settings.json b/Code/heeeeeeeloWorld/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/heeeeeeeloWorld/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/heeeeeeeloWorld/README.md b/Code/heeeeeeeloWorld/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/heeeeeeeloWorld/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/heeeeeeeloWorld/bin/App.class b/Code/heeeeeeeloWorld/bin/App.class new file mode 100644 index 0000000..7b83e68 Binary files /dev/null and b/Code/heeeeeeeloWorld/bin/App.class differ diff --git a/Code/heeeeeeeloWorld/src/App.java b/Code/heeeeeeeloWorld/src/App.java new file mode 100644 index 0000000..b64ab78 --- /dev/null +++ b/Code/heeeeeeeloWorld/src/App.java @@ -0,0 +1,74 @@ +import java.util.Random; + +public class App { + public static void main(String[] args) { + String helloWorldMessage = concatenateLetters( + getH(), getE(), getL(), getL(), getO(), + getComma(), getSpace(), + getW(), getO(), getR(), getL(), getD(), getExclamation()); + + printMessageWithFunnyLoop(helloWorldMessage); + } + + private static String concatenateLetters(String... letters) { + StringBuilder stringBuilder = new StringBuilder(); + for (String letter : letters) { + stringBuilder.append(letter); + } + return stringBuilder.toString(); + } + + private static String getH() { + return "H"; + } + + private static String getE() { + return "e"; + } + + private static String getL() { + return "l"; + } + + private static String getO() { + return "o"; + } + + private static String getComma() { + return ","; + } + + private static String getSpace() { + return " "; + } + + private static String getW() { + return "W"; + } + + private static String getR() { + return "r"; + } + + private static String getD() { + return "d"; + } + + private static String getExclamation() { + return "!"; + } + + private static void printMessageWithFunnyLoop(String message) { + System.out.println(message); + + // Adding a funny and unnecessary loop + Random random = new Random(); + for (int i = 0; i < 10; i++) { + int numHa = random.nextInt(5) + 2; // Randomly choose between 2 and 6 "ha"s + for (int j = 0; j < numHa; j++) { + System.out.print("ha"); + } + System.out.print(" "); + } + } +} diff --git a/Code/helpMePlease/.vscode/settings.json b/Code/helpMePlease/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/helpMePlease/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/helpMePlease/README.md b/Code/helpMePlease/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/helpMePlease/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/helpMePlease/bin/App.class b/Code/helpMePlease/bin/App.class new file mode 100644 index 0000000..df1684e Binary files /dev/null and b/Code/helpMePlease/bin/App.class differ diff --git a/Code/helpMePlease/src/App.java b/Code/helpMePlease/src/App.java new file mode 100644 index 0000000..97792d5 --- /dev/null +++ b/Code/helpMePlease/src/App.java @@ -0,0 +1,17 @@ +public class App { + public static void main(String[] args) { + // (Kein) Casting notwendig + int intValue = 42; + double doubleValue = intValue; + + System.out.println("int value: " + intValue); + System.out.println("double value: " + doubleValue); + + // Casting nötig + double largeDoubleValue = 123.456; + int intValueFromDouble = (int) largeDoubleValue; + + System.out.println("double value: " + largeDoubleValue); + System.out.println("int value from double: " + intValueFromDouble); + } +} diff --git a/Code/ifToSwitch/.vscode/settings.json b/Code/ifToSwitch/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/ifToSwitch/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/ifToSwitch/README.md b/Code/ifToSwitch/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/ifToSwitch/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/ifToSwitch/bin/App.class b/Code/ifToSwitch/bin/App.class new file mode 100644 index 0000000..3c45c2c Binary files /dev/null and b/Code/ifToSwitch/bin/App.class differ diff --git a/Code/ifToSwitch/bin/App2.class b/Code/ifToSwitch/bin/App2.class new file mode 100644 index 0000000..7827b43 Binary files /dev/null and b/Code/ifToSwitch/bin/App2.class differ diff --git a/Code/ifToSwitch/src/App.java b/Code/ifToSwitch/src/App.java new file mode 100644 index 0000000..1d7b2b1 --- /dev/null +++ b/Code/ifToSwitch/src/App.java @@ -0,0 +1,103 @@ +import java.util.Scanner; + +public class App { + public static void main(String[] args) { + Scanner scan = new Scanner(System.in); + System.out.println("Deine Sprache/Your language (de/en)"); + String deineSprache = scan.next(); + int arbeitstagNummer = 0; + + if (deineSprache.equals("de")) { + System.out.println("Arbeitstag-Nummer (1=Montag, 2=Dienstag, 3=Mittwoch, 4=Donnerstag, 5=Freitag)"); + arbeitstagNummer = scan.nextInt(); + } else if (deineSprache.equals("en")) { + System.out.println("Workday number (1=Monday, 2=Tuesday, 3=Wednesday, 4=Thursday, 5=Friday)"); + arbeitstagNummer = scan.nextInt(); + } else { + System.out.println("Error"); + } + scan.close(); + + if (deineSprache.equalsIgnoreCase("de")) { + switch (arbeitstagNummer) { + case 1: + System.out.println("Montag"); + break; + case 2: + System.out.println("Dienstag"); + break; + case 3: + System.out.println("Mittwoch"); + break; + case 4: + System.out.println("Donnerstag"); + break; + case 5: + System.out.println("Freitag"); + break; + default: + System.out.println("error"); + break; + } + } else if (deineSprache.equalsIgnoreCase("en")) { + + switch (arbeitstagNummer) { + case 1: + System.out.println("Monday"); + break; + case 2: + System.out.println("Tuesday"); + break; + case 3: + System.out.println("Wednesday"); + break; + case 4: + System.out.println("Thursday"); + break; + case 5: + System.out.println("Friday"); + break; + default: + System.out.println("error"); + break; + } + } else { + System.out.println("Sprache nicht erkannt"); + System.out.println("unfamiliar language"); + } + + // Code von der Herr Steiner + /* + * if (deineSprache.equalsIgnoreCase("de")) { + * if (arbeitstagNummer == 1) + * System.out.println("Montag"); + * else if (arbeitstagNummer == 2) + * System.out.println("Dienstag"); + * else if (arbeitstagNummer == 3) + * System.out.println("Mittwoch"); + * else if (arbeitstagNummer == 4) + * System.out.println("Donnerstag"); + * else if (arbeitstagNummer == 5) + * System.out.println("Freitag"); + * else + * System.out.println("Das ist kein Arbeitstag."); + * } else if (deineSprache.equalsIgnoreCase("en")) { + * if (arbeitstagNummer == 1) + * System.out.println("Monday"); + * else if (arbeitstagNummer == 2) + * System.out.println("Tuesday"); + * else if (arbeitstagNummer == 3) + * System.out.println("Wednesday"); + * else if (arbeitstagNummer == 4) + * System.out.println("Thursday"); + * else if (arbeitstagNummer == 5) + * System.out.println("Friday"); + * else + * System.out.println("This is not a working day."); + * } else { + * System.out.println("Diese Sprache kenne ich nicht: " + deineSprache); + * } + */ + + } +} diff --git a/Code/ifToSwitch/src/App2.java b/Code/ifToSwitch/src/App2.java new file mode 100644 index 0000000..6978b05 --- /dev/null +++ b/Code/ifToSwitch/src/App2.java @@ -0,0 +1,73 @@ +import java.util.Scanner; + +public class App2 { + public static void main(String[] args) { + Scanner scan = new Scanner(System.in); + System.out.println("Deine Sprache/Your language (de/en)"); + String deineSprache = scan.next(); + int arbeitstagNummer = 0; + + switch (deineSprache) { + case "en": + case "En": + case "eN": + case "EN": + System.out.println("Workday number (1=Monday, 2=Tuesday, 3=Wednesday, 4=Thursday, 5=Friday)"); + arbeitstagNummer = scan.nextInt(); + switch (arbeitstagNummer) { + case 1: + System.out.println("Monday"); + break; + case 2: + System.out.println("Tuesday"); + break; + case 3: + System.out.println("Wednesday"); + break; + case 4: + System.out.println("Thursday"); + break; + case 5: + System.out.println("Friday"); + break; + default: + System.out.println("error"); + break; + } + break; + case "de": + case "De": + case "dE": + case "DE": + System.out.println("Arbeitstag-Nummer (1=Montag, 2=Dienstag, 3=Mittwoch, 4=Donnerstag, 5=Freitag)"); + arbeitstagNummer = scan.nextInt(); + switch (arbeitstagNummer) { + case 1: + System.out.println("Montag"); + break; + case 2: + System.out.println("Dienstag"); + break; + case 3: + System.out.println("Mittwoch"); + break; + case 4: + System.out.println("Donnerstag"); + break; + case 5: + System.out.println("Freitag"); + break; + default: + System.out.println("error"); + break; + } + break; + default: + System.out.println("Error"); + System.out.println("Sprache nicht erkannt"); + System.out.println("unfamiliar language"); + break; + } + scan.close(); + } +} \ No newline at end of file diff --git a/Code/interationBottles/.vscode/settings.json b/Code/interationBottles/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/interationBottles/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/interationBottles/README.md b/Code/interationBottles/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/interationBottles/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/interationBottles/bin/App.class b/Code/interationBottles/bin/App.class new file mode 100644 index 0000000..1a74d4c Binary files /dev/null and b/Code/interationBottles/bin/App.class differ diff --git a/Code/interationBottles/src/App.java b/Code/interationBottles/src/App.java new file mode 100644 index 0000000..385f0de --- /dev/null +++ b/Code/interationBottles/src/App.java @@ -0,0 +1,25 @@ +import java.util.Scanner; + +public class App { + static Scanner scan = new Scanner(System.in); + + public static void main(String[] args) throws Exception { + { + int emptyBottle = 0; + System.out.println("Give me the volume of an empty bottle (in ml)"); + int maxVolume = scan.nextInt(); + System.out.println("Give me the volume for all the full bottles (in ml)"); + int fullBottle = scan.nextInt(); + int numberOfRuns = 0; + + while (emptyBottle < maxVolume) { + numberOfRuns++; + System.out.println(numberOfRuns + " run"); + emptyBottle += fullBottle; + } + System.out.println("it takes " + numberOfRuns + " bottles to fill the empty one"); + System.out.println("end of code"); + + } + } +} diff --git a/Code/interationNumbers/.vscode/settings.json b/Code/interationNumbers/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/interationNumbers/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/interationNumbers/README.md b/Code/interationNumbers/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/interationNumbers/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/interationNumbers/bin/App.class b/Code/interationNumbers/bin/App.class new file mode 100644 index 0000000..bd6deae Binary files /dev/null and b/Code/interationNumbers/bin/App.class differ diff --git a/Code/interationNumbers/src/App.java b/Code/interationNumbers/src/App.java new file mode 100644 index 0000000..a0b83aa --- /dev/null +++ b/Code/interationNumbers/src/App.java @@ -0,0 +1,11 @@ +public class App { + public static void main(String[] args) throws Exception { + int countingNumber = 0; + + while (countingNumber <= 1000) { + System.out.println(countingNumber); + countingNumber++; + } + System.out.println("End of code"); + } +} diff --git a/Code/itsTheFinalCountDown/.vscode/settings.json b/Code/itsTheFinalCountDown/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/itsTheFinalCountDown/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/itsTheFinalCountDown/README.md b/Code/itsTheFinalCountDown/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/itsTheFinalCountDown/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/itsTheFinalCountDown/bin/App.class b/Code/itsTheFinalCountDown/bin/App.class new file mode 100644 index 0000000..00ef7db Binary files /dev/null and b/Code/itsTheFinalCountDown/bin/App.class differ diff --git a/Code/itsTheFinalCountDown/src/App.java b/Code/itsTheFinalCountDown/src/App.java new file mode 100644 index 0000000..de867ac --- /dev/null +++ b/Code/itsTheFinalCountDown/src/App.java @@ -0,0 +1,23 @@ +public class App { + + // Assuming an interest rate of 5% for demonstration purposes + public static final double INTEREST_RATE = 0.05; + + public static void main(String[] args) { + + double accountBalance = 1000.0; // Initial account balance + double creditedInterest = accountBalance * INTEREST_RATE; + + System.out.println("Initial Account Balance: $" + accountBalance); + System.out.println("Credited Interest at " + (INTEREST_RATE * 100) + "%: $" + creditedInterest); + + // Update account balance with credited interest + accountBalance += creditedInterest; + + System.out.println("Updated Account Balance: $" + accountBalance); + } + + public static void getTest() { + + } +} diff --git a/Code/jahrGueltig/.vscode/settings.json b/Code/jahrGueltig/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/jahrGueltig/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/jahrGueltig/README.md b/Code/jahrGueltig/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/jahrGueltig/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/jahrGueltig/bin/App.class b/Code/jahrGueltig/bin/App.class new file mode 100644 index 0000000..3121333 Binary files /dev/null and b/Code/jahrGueltig/bin/App.class differ diff --git a/Code/jahrGueltig/src/App.java b/Code/jahrGueltig/src/App.java new file mode 100644 index 0000000..dc8d1cf --- /dev/null +++ b/Code/jahrGueltig/src/App.java @@ -0,0 +1,117 @@ +// Luca Burger +// AUFGABE 1 + +import java.util.Scanner; + +public class App { + static Scanner scan = new Scanner(System.in); + + public static void main(String[] args) throws Exception { + // Nutzer Eingabe + System.out.println("Einen Tag bitte (als Zahl)"); + int tag = scan.nextInt(); + System.out.println("Einen Monat bitte (als Zahl)"); + int monat = scan.nextInt(); + System.out.println("Ein jahr (für vor Christi negative verwenden)"); + int jahr = scan.nextInt(); + System.out.println("1. Januar " + jahr + " = 0, Montag .... 6, Sonntag"); + int startTag = scan.nextInt(); + + int tagImJahr = 0; + if (tag > 0 && tag <= 31) { + switch (monat) { + case 1: + tagImJahr = tag; + break; + case 2: + tagImJahr = tag; + tagImJahr = tagImJahr + 31; + break; + case 3: + tagImJahr = tag; + tagImJahr = tagImJahr + 59; + break; + case 4: + tagImJahr = tag; + tagImJahr = tagImJahr + 90; + break; + case 5: + tagImJahr = tag; + tagImJahr = tagImJahr + 120; + break; + case 6: + tagImJahr = tag; + tagImJahr = tagImJahr + 150; + break; + case 7: + tagImJahr = tag; + tagImJahr = tagImJahr + 181; + break; + case 8: + tagImJahr = tag; + tagImJahr = tagImJahr + 212; + break; + case 9: + tagImJahr = tag; + tagImJahr = tagImJahr + 242; + break; + case 10: + tagImJahr = tag; + tagImJahr = tagImJahr + 273; + break; + case 11: + tagImJahr = tag; + tagImJahr = tagImJahr + 303; + break; + case 12: + tagImJahr = tag; + tagImJahr = tagImJahr + 334; + break; + default: + System.out.println("error"); + break; + } + } else { + System.out.println("error"); + } + + if (jahr % 4 == 0 && (jahr % 100 != 0 || jahr % 400 == 0)) { + tagImJahr++; + } + System.out.println("Datum: " + tag + "." + monat + "." + jahr); + System.out.println(tagImJahr + ". Tag im Jahr"); + + // Berechnung welcher Wochentag + double woche = tagImJahr / 7; + System.out.println("Kalenderwoche: " + (int) woche); + int wochentag = (int) woche / startTag; + wochentag = -1; // Berechnung hat nicht Funktioniert :( + + switch (wochentag) { + case 0: + System.out.println("Montag"); + break; + case 1: + System.out.println("Dienstag"); + break; + case 2: + System.out.println("Mittwoch"); + break; + case 3: + System.out.println("Donnerstag"); + break; + case 4: + System.out.println("Freitag"); + break; + case 5: + System.out.println("Samstag"); + break; + case 6: + System.out.println("Sonntag"); + break; + default: + System.out.println("Wochentag konnte nicht berechnet werden"); + break; + } + } +} diff --git a/Code/leadderGameProject/.vscode/settings.json b/Code/leadderGameProject/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/leadderGameProject/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/leadderGameProject/README.md b/Code/leadderGameProject/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/leadderGameProject/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/leadderGameProject/bin/App.class b/Code/leadderGameProject/bin/App.class new file mode 100644 index 0000000..6005437 Binary files /dev/null and b/Code/leadderGameProject/bin/App.class differ diff --git a/Code/leadderGameProject/src/App.class b/Code/leadderGameProject/src/App.class new file mode 100644 index 0000000..07f3c85 Binary files /dev/null and b/Code/leadderGameProject/src/App.class differ diff --git a/Code/leadderGameProject/src/App.java b/Code/leadderGameProject/src/App.java new file mode 100644 index 0000000..9105d40 --- /dev/null +++ b/Code/leadderGameProject/src/App.java @@ -0,0 +1,326 @@ +import java.util.Scanner; + +public class App { + private static String[] playerNames; + private static int[] playerPositions; + private static int currentPlayerIndex = 0; + private static int[] ladderSnakes = new int[130]; + private static Scanner scanner = new Scanner(System.in); + + public static void main(String[] args) { + startGame(); + while (playTurn()) + System.out.println("====================================="); + scanner.close(); + } + + // Initialize the game + private static void startGame() { + System.out.println("Welcome to Snakes and Ladders!"); + displayRules(); + setPlayerNames(); + determinePlayerOrder(); + playerPositions = new int[playerNames.length]; + initializeLadderSnakes(); + } + + // Placement of leadders and snakes + private static void initializeLadderSnakes() { + ladderSnakes[3] = 49; + ladderSnakes[5] = 26; + ladderSnakes[14] = 9; + ladderSnakes[21] = 63; + ladderSnakes[47] = 24; + ladderSnakes[52] = 74; + ladderSnakes[54] = 21; + ladderSnakes[58] = 82; + ladderSnakes[66] = 88; + ladderSnakes[89] = 61; + ladderSnakes[94] = 122; + ladderSnakes[99] = 116; + ladderSnakes[101] = 76; + ladderSnakes[104] = 126; + ladderSnakes[110] = 91; + ladderSnakes[128] = 112; + } + + // the rules + private static void displayRules() { + System.out.println( + "Rules:\n" + + "1. The game is played on a board with 130 squares numbered from 1 to 130.\n" + + "2. The goal is to reach square 130 exactly.\n" + + "3. Each player takes turns rolling a six-sided die.\n" + + "4. Move forward the number of squares equal to the dice roll.\n" + + "5. If a player lands on a square with a ladder, they climb the ladder to the top.\n" + + "6. If a player lands on a square with the head of a snake, they slide down to the tail.\n" + + "7. The first player to reach square 130 wins the game!\n"); + } + + // Name input and number of Players + private static void setPlayerNames() { + int numPlayers = getUserInt("Enter the number of players: "); + playerNames = new String[numPlayers]; + System.out.println("Enter the names of the players:"); + for (int i = 0; i < numPlayers; i++) { + playerNames[i] = getUserName("Enter name for player " + (i + 1) + ": "); + } + System.out.println("Player names set!"); + } + + // Determine player order + private static void determinePlayerOrder() { + if (playerNames.length > 1) { + int maxIndex = determineMaxRollIndex(); + if (maxIndex != 0) + swapPlayers(0, maxIndex); + displayPlayerOrder(); + } + } + + // who rolled the highest + private static int determineMaxRollIndex() { + int maxIndex = 0; + int maxRoll = -1; + for (int i = 0; i < playerNames.length; i++) { + int roll; + do { + roll = getUserInt(playerNames[i] + ", what did you roll?"); + if (!isValidMove(roll)) + System.out.println("Invalid move. Try again."); + } while (!isValidMove(roll)); + if (roll > maxRoll) { + maxRoll = roll; + maxIndex = i; + } + } + return maxIndex; + } + + // Display the order + private static void displayPlayerOrder() { + System.out.println("Player order after determining:"); + for (int i = 0; i < playerNames.length; i++) + System.out.println((i + 1) + ". " + playerNames[i]); + } + + private static void swapPlayers(int index1, int index2) { + String tempName = playerNames[index1]; + playerNames[index1] = playerNames[index2]; + playerNames[index2] = tempName; + } + + private static boolean playTurn() { + // Start at 0 at the begining of the first turn placed onto the board + if (playerPositions[currentPlayerIndex] == 0) + playerPositions[currentPlayerIndex] = 1; + + boolean extraTurn = false; + + do { + displayPlayerStatus(); + int move = getValidMove(); + if (move == -1) { + handleRageQuit(); + break; + } else if (move == -2) { + handleGameEnd(); + return false; + } else { + System.out.println(playerNames[currentPlayerIndex] + " rolled a " + move + "."); + updatePlayerPosition(move); + int destination = handleSpecialFields(); + + if (destination != playerPositions[currentPlayerIndex]) { + System.out.print( + playerNames[currentPlayerIndex] + " goes from " + playerNames[currentPlayerIndex] + " to " + + destination + ". "); + + if (playerPositions[currentPlayerIndex] < destination) { + System.out.println("Climb the ladder!"); + } else { + System.out.println("Slide the snakes"); + } + + playerPositions[currentPlayerIndex] = destination; + } + printPlayerPositions(); + + if (playerPositions[currentPlayerIndex] == 130) { + System.out.println(playerNames[currentPlayerIndex] + " wins the game!"); + return false; + } + + extraTurn = (move == 6); // Check if the player rolled a 6 for an additional turn + if (!extraTurn) { + currentPlayerIndex = (currentPlayerIndex + 1) % playerNames.length; + } + } + } while (extraTurn); + + return true; + } + + // display all relevant information + private static void displayPlayerStatus() { + System.out.println( + "Current position for " + playerNames[currentPlayerIndex] + ": " + playerPositions[currentPlayerIndex]); + System.out.println("Enter -1 for a ragequit"); + System.out.println("Enter -2 to end the game for all."); + System.out.println(playerNames[currentPlayerIndex] + "'s turn."); + // int consequences = mostOptimalMove(currentPlayerIndex); + // if (consequences != 0) { + System.out.println("The most optimal roll is: " + mostOptimalMove(playerPositions[currentPlayerIndex])); + // } + } + + // test if it is a valid move + private static int getValidMove() { + int move; + boolean validMove; + do { + move = getUserInt("Enter the dice roll for " + playerNames[currentPlayerIndex] + ": "); + if (move == -1 || move == -2) { + return move; + } else { + validMove = isValidMove(move); + if (!validMove) + System.out.println("Invalid move! Please try again."); + } + } while (!validMove); + return move; + } + + private static void handleRageQuit() { + System.out.println("Player " + playerNames[currentPlayerIndex] + + " ragequit. But that's not an option xD. Going back to position 1."); + playerPositions[currentPlayerIndex] = 1; + } + + private static void handleGameEnd() { + System.out.println(playerNames[currentPlayerIndex] + + " has ended the game"); + playerPositions[currentPlayerIndex] = -2; + System.out.println("Game ended. Thanks for playing!"); + } + + private static void updatePlayerPosition(int move) { + int newPosition = playerPositions[currentPlayerIndex] + move; + + if (newPosition == 130) { + playerPositions[currentPlayerIndex] = newPosition; + System.out.println(playerNames[currentPlayerIndex] + " wins the game!"); + } else if (newPosition > 130) { + int overshoot = newPosition - 130; + playerPositions[currentPlayerIndex] = 130 - overshoot; + System.out.println("Oops! " + playerNames[currentPlayerIndex] + " overshot 130 and walked back."); + } else { + playerPositions[currentPlayerIndex] = newPosition; + } + } + + private static int handleSpecialFields() { + int currentPosition = playerPositions[currentPlayerIndex]; + + for (int i = 0; i < ladderSnakes.length; i++) { + if (currentPosition == i && ladderSnakes[i] != 0) { + int destination = ladderSnakes[i]; + System.out.print(playerNames[currentPlayerIndex] + " goes from " + currentPosition + " to " + + destination + ". "); + + if (currentPosition < destination) { + System.out.println("Climb the ladder!"); + } else { + System.out.println("Slide the snakes"); + } + + return destination; + } + } + + // If no ladder or snake is encountered, return the current position + return currentPosition; + } + + private static void printPlayerPositions() { + for (int i = 0; i < playerNames.length; i++) + System.out.println(playerNames[i] + " Position: " + playerPositions[i] + " | "); + } + + private static boolean isValidMove(int move) { + return move >= 1 && move <= 6; + } + + private static String getUserName(String prompt) { + System.out.println(prompt); + String name = scanner.next(); + return name; + } + + private static int getUserInt(String prompt) { + int number = 0; + while (number == 0) { + System.out.println(prompt); + try { + number = scanner.nextInt(); + } catch (Exception e) { + number = 0; + scanner.next(); + } + } + return number; + } + + private static int mostOptimalMove(int currentPosition) { + int mostOptimalRoll = 0; + int maxPosition = currentPosition; + + // for (int i = 1; i <= 6; i++) { + // int simulatedPosition = currentPosition + i; + + // // Check for ladder or snake at the simulated position + // if (simulatedPosition < ladderSnakes.length && + // ladderSnakes[simulatedPosition] != 0) { + // // Adjust simulated position without modifying ladderSnakes + // simulatedPosition = ladderSnakes[simulatedPosition]; + // } + + // // Check if this roll leads to a position further ahead + // if (simulatedPosition > maxPosition) { + // maxPosition = simulatedPosition; + // mostOptimalRoll = i; + // } + + // System.out.println("If you roll a " + i + ", you land on: " + + // simulatedPosition); + // } + + // return mostOptimalRoll; + // } + + int optimalRoll = 0; + for (int i = 1; i <= 6; i++) { + int simulatedPosition = currentPosition + i; + + // Check for ladder or snake at the simulated position + for (int j = 0; j < ladderSnakes.length; j++) { + if (simulatedPosition == j && ladderSnakes[j] != 0) { + // Adjust simulated position without modifying ladderSnakes + simulatedPosition = ladderSnakes[j]; + break; + } + } + + if (simulatedPosition > maxPosition) { + maxPosition = simulatedPosition; + optimalRoll = i; + } + + if (playerPositions[currentPlayerIndex] >= 124) { + optimalRoll = 130 - playerPositions[currentPlayerIndex]; + } + } + return optimalRoll; + } + +} diff --git a/Code/lmao/.vscode/settings.json b/Code/lmao/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/lmao/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/lmao/README.md b/Code/lmao/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/lmao/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/lmao/bin/App.class b/Code/lmao/bin/App.class new file mode 100644 index 0000000..da9d627 Binary files /dev/null and b/Code/lmao/bin/App.class differ diff --git a/Code/lmao/src/App.java b/Code/lmao/src/App.java new file mode 100644 index 0000000..13b9f34 --- /dev/null +++ b/Code/lmao/src/App.java @@ -0,0 +1,22 @@ +public class App { + public static void main(String[] args) { + // Use unconventional techniques for readability + String message = "You fool, I'll smite yee!"; + String complexSmiteMessage = invertCasing(message); + printMessage(complexSmiteMessage); + } + + private static String invertCasing(String input) { + char[] characters = input.toCharArray(); + for (int i = 0; i < characters.length; i++) { + if (Character.isLetter(characters[i])) { + characters[i] ^= (1 << 5); // Invert the case using XOR + } + } + return new String(characters); + } + + private static void printMessage(String message) { + System.out.println(message); + } +} diff --git a/Code/logicalUnd/.vscode/settings.json b/Code/logicalUnd/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/logicalUnd/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/logicalUnd/README.md b/Code/logicalUnd/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/logicalUnd/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/logicalUnd/bin/App.class b/Code/logicalUnd/bin/App.class new file mode 100644 index 0000000..c0a0501 Binary files /dev/null and b/Code/logicalUnd/bin/App.class differ diff --git a/Code/logicalUnd/src/App.java b/Code/logicalUnd/src/App.java new file mode 100644 index 0000000..b2d5c89 --- /dev/null +++ b/Code/logicalUnd/src/App.java @@ -0,0 +1,41 @@ +/* +Formulieren Sie die folgenden Aussagen als if)-Bcdingung: +a) y ist positiv. +b) a liegt im Intervall —2 bis 5.3. +c) Der Preis ist kleiner als 5% von 20.— CHE +d) x ist kleiner als 5 und ungerade. +e) t liegt im Intervall [—3, 6) oder im Intervall (2, 8). Die Intervallgrenlßn +den üblicherweise mit eckigen oder runden Klammern angegeben. +Bei eckigen Klammern gehören die Intervallgrenzen dazu (inklusive). Bei +runden Klammern gehören die Grenzen nicht dazu (exklusive). In der Auf- +gabe gehört also z. B. die Zahl —3 dazu, wohingegen die Zahl 8 nicht Teil des +Intervalls ist. +*/ + +public class App { + public static void main(String[] args) throws Exception { + int y = 0; + double a = 5.3; + double price = 0; + int x = 3; + int t = 4; + + if (y >= 0) { + System.out.println("yes"); + } + if (a >= -2 && a <= 5.3) { + System.out.println("YES"); + } + if (price < 20 * 0.05) { + System.out.println("YES!"); + } + if (x < 5 && x % 2 >= 0) { + System.out.println("tricky"); + } + if ((t >= -3 && t < 6) || (t > 2 && t < 8)) { + System.out.println("YEEEEEES"); + } + + } + +} diff --git a/Code/macDonalds/.vscode/settings.json b/Code/macDonalds/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/macDonalds/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/macDonalds/README.md b/Code/macDonalds/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/macDonalds/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/macDonalds/bin/App.class b/Code/macDonalds/bin/App.class new file mode 100644 index 0000000..a343a61 Binary files /dev/null and b/Code/macDonalds/bin/App.class differ diff --git a/Code/macDonalds/src/App.java b/Code/macDonalds/src/App.java new file mode 100644 index 0000000..5088013 --- /dev/null +++ b/Code/macDonalds/src/App.java @@ -0,0 +1,38 @@ +import java.util.Scanner; + +public class App { + static Scanner scan = new Scanner(System.in); + + public static void main(String[] args) throws Exception { + + System.out.println("Möchtest du etwas bestellen? j/n"); + boolean etwasBestellt = false; + String orderSomething = scan.nextLine(); + + if (orderSomething.equals("j")) { + System.out.println("Möchtest du ein Burger? j/n"); + orderSomething = scan.nextLine(); + + if (orderSomething.equals("j")) { + System.out.println("Ein Burger wurde bestellt"); + etwasBestellt = true; + } + + System.out.println("Möchtest du Eiscreme bestellen? j/n"); + orderSomething = scan.nextLine(); + + if (orderSomething.equals("j")) { + System.out.println("Eiscreme wurde bestellt"); + etwasBestellt = true; + } + + } else { + System.out.println("Gut so - so bleibst du ihn Form"); + } + if (!etwasBestellt) { + System.out.println("Kommen sie wieder wenn Sie etwas bestellen wollen!"); + } + scan.close(); + } + +} \ No newline at end of file diff --git a/Code/math1o1/.vscode/settings.json b/Code/math1o1/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/math1o1/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/math1o1/README.md b/Code/math1o1/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/math1o1/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/math1o1/bin/App.class b/Code/math1o1/bin/App.class new file mode 100644 index 0000000..1d4441a Binary files /dev/null and b/Code/math1o1/bin/App.class differ diff --git a/Code/math1o1/src/App.java b/Code/math1o1/src/App.java new file mode 100644 index 0000000..0bd8791 --- /dev/null +++ b/Code/math1o1/src/App.java @@ -0,0 +1,13 @@ +public class App { + public static void main(String[] args) throws Exception { + int result = 0; + + for (int numberOne = 0; numberOne <= 10; numberOne++) { + for (int numberTwo = 0; numberTwo <= 10; numberTwo++) { + result = numberOne * numberTwo; + System.out.println(numberOne + " times " + numberTwo + " : " + result); + } + System.out.println(); + } + } +} diff --git a/Code/math2o2/.vscode/settings.json b/Code/math2o2/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/math2o2/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/math2o2/README.md b/Code/math2o2/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/math2o2/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/math2o2/bin/App.class b/Code/math2o2/bin/App.class new file mode 100644 index 0000000..2fa2f69 Binary files /dev/null and b/Code/math2o2/bin/App.class differ diff --git a/Code/math2o2/src/App.java b/Code/math2o2/src/App.java new file mode 100644 index 0000000..ab67f4d --- /dev/null +++ b/Code/math2o2/src/App.java @@ -0,0 +1,12 @@ +import java.util.Random; +import java.util.Scanner; + +public class App { + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + Random random = new Random(); + + int randomNumber = random.nextInt(10) + 1; + + } +} \ No newline at end of file diff --git a/Code/methodeNumberOne/.vscode/settings.json b/Code/methodeNumberOne/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/methodeNumberOne/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/methodeNumberOne/README.md b/Code/methodeNumberOne/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/methodeNumberOne/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/methodeNumberOne/bin/App.class b/Code/methodeNumberOne/bin/App.class new file mode 100644 index 0000000..7e87473 Binary files /dev/null and b/Code/methodeNumberOne/bin/App.class differ diff --git a/Code/methodeNumberOne/src/App.java b/Code/methodeNumberOne/src/App.java new file mode 100644 index 0000000..eb2a6bc --- /dev/null +++ b/Code/methodeNumberOne/src/App.java @@ -0,0 +1,52 @@ +import java.util.Scanner; + +public class App { + static Scanner scan = new Scanner(System.in); + + public static void main(String[] args) throws Exception { + System.out.println("Which char (if you feel funky even multiple) do you want to demonstrate the number?"); + String diagram = scan.nextLine(); + + System.out.println("Text please"); + String textOne = scan.nextLine(); + System.out.println("Text please"); + String textTwo = scan.nextLine(); + System.out.println("Give me a number"); + int numberOne = scan.nextInt(); + System.out.println("Give me a number"); + int numberTwo = scan.nextInt(); + + printText(textOne, numberOne, diagram); + printText(textTwo, numberTwo, diagram); + + int numericSum = calcSum(numberOne, numberTwo); + System.out.println("Numeric Sum: " + numericSum); + + charSum(diagram, numericSum); + } + + public static void printText(String text, int zahl, String diagram) { + System.out.println(text); + printChar(zahl, diagram); + System.out.println(); + } + + public static void printChar(int zahl, String diagram) { + for (int i = 0; i < zahl; i++) { + System.out.print(diagram); + } + System.out.println(); + } + + public static int calcSum(int summandA, int summandB) { + return summandA + summandB; + } + + public static void charSum(String diagram, int numericSum) { + // Print the specified character the same number of times as the numeric sum + for (int i = 0; i < numericSum; i++) { + System.out.print(diagram); + } + System.out.println(); + } +} diff --git a/Code/mineField/.vscode/settings.json b/Code/mineField/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/mineField/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/mineField/README.md b/Code/mineField/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/mineField/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/mineField/bin/App.class b/Code/mineField/bin/App.class new file mode 100644 index 0000000..805e4fc Binary files /dev/null and b/Code/mineField/bin/App.class differ diff --git a/Code/mineField/src/App.java b/Code/mineField/src/App.java new file mode 100644 index 0000000..60cae95 --- /dev/null +++ b/Code/mineField/src/App.java @@ -0,0 +1,231 @@ +import java.util.Random; +import java.util.Scanner; + +public class App { + public static final int SIZE = 100; + public static Random rand = new Random(); + public static Scanner scanner = new Scanner(System.in); + public static int score = 0; + + public static void main(String[] args) { + boolean isGameRunning = true; + startGame(isGameRunning); + } + + /** + * Displays options before the game starts. + * Options include viewing rules, points information, starting the game, or + * ending the game. + */ + public static void startGame(boolean isGameRunning) { + while (isGameRunning) { + System.out.println("Options:"); + System.out.println("1. Rules"); + System.out.println("2. Points"); + System.out.println("0. Start the game"); + System.out.println("-1. End the game"); + + int choice = getInput("Enter your choice"); + + switch (choice) { + case 1: + displayRules(); + break; + case 2: + displayPoints(); + break; + case 0: + playGame(); + break; + case -1: + isGameRunning = false; + endGame("Game ended before starting", 0); + break; + default: + System.out.println("Invalid choice. Please enter a valid option."); + } + } + } + + /** + * Displays the rules of the game. + */ + public static void displayRules() { + System.out.println("Game Rules:"); + System.out.println("1. You start at position 0 on a board of size " + SIZE + "."); + System.out.println("2. Your goal is to reach the end of the board without hitting any mines."); + System.out.println("3. Mines are randomly placed on the board."); + System.out.println("4. You can move a maximum of 6 spaces in each turn."); + System.out.println("5. Hitting a mine ends the game."); + System.out.println("6. Reaching the last space wins the game."); + } + + /** + * Displays information about the points system in the game. + */ + public static void displayPoints() { + System.out.println("Points Information:"); + System.out.println("1. Start with a score of 0."); + System.out.println("2. Each correct move earns 5 points."); + System.out.println("3. Using a tip deducts 10 points."); + System.out.println("4. Final score is (2 * roundsSurvived + score)."); + System.out.println("5. Winning grants a bonus of 50 points."); + } + + /** + * Initiates the game, allowing the player to play. + */ + public static void playGame() { + int numMines = getInput("How many mines should be placed on the board"); + boolean[] board = new boolean[SIZE]; + boolean gameRun = true; + int playerPos = 1; + int roundsSurvived = 0; + + placeMines(numMines, board); + + while (gameRun) { + int move = getInput("How many spaces do you want to move? (Max 6, 7 for a tip, 0 to quit)"); + + if (!isValidMove(move)) { + System.out.println("Error: Out of bounds"); + continue; + } + + if (move == 0) { + System.out.println("Bye Bye"); + break; + } else if (move == 7) { + giveTip(playerPos, board); + score -= 10; // Deduct 10 points for using a tip + continue; + } + + if (board[playerPos]) { + gameRun = false; + endGame("You hit a mine and exploded", roundsSurvived); + break; + } + + if (isWinningPosition(playerPos, move, board)) { + gameRun = false; + endGame("Congratulations! You reached the end and won the game!", roundsSurvived); + break; + } + + score += 5; // Gain 5 points for a right move + roundsSurvived++; + playerPos += move; + + System.out.println("You're on space: " + playerPos + " | Score: " + score); + } + } + + /** + * Obtains user input with a given message. + * + * @param message The message to display when prompting for input. + * @return The user's input. + */ + public static int getInput(String message) { + System.out.print(message + " "); + return scanner.nextInt(); + } + + /** + * Places mines on the game board. + * + * @param numMines The number of mines to be placed. + * @param board The game board. + */ + public static void placeMines(int numMines, boolean[] board) { + for (int i = 0; i < numMines; i++) { + int randomPos = rand.nextInt(SIZE); + board[randomPos] = true; + } + } + + /** + * Checks if a move is valid. + * + * @param move The move to be checked. + * @return True if the move is valid, false otherwise. + */ + public static boolean isValidMove(int move) { + return move >= 0 && move <= 6 || move == 7; + } + + /** + * Checks if the player is in a winning position. + * + * @param playerPos The current position of the player. + * @param move The move made by the player. + * @param board The game board. + * @return True if the player is in a winning position, false otherwise. + */ + public static boolean isWinningPosition(int playerPos, int move, boolean[] board) { + return playerPos == SIZE - 1 || playerPos + move >= SIZE; + } + + /** + * Provides a tip to the player about the nearest bomb. + * + * @param playerPos The current position of the player. + * @param board The game board. + */ + public static void giveTip(int playerPos, boolean[] board) { + int rightDistance = findNearestBombDistance(playerPos, board); + + if (rightDistance == -1) { + System.out.println("Tip: No bombs nearby, you're safe!"); + } else { + System.out.println("Tip: The nearest bomb is on field " + rightDistance + "."); + } + } + + /** + * Finds the distance to the nearest bomb in the forward direction. + * + * @param playerPos The current position of the player. + * @param board The game board. + * @return The distance to the nearest bomb, or -1 if no bomb is found in the + * given direction. + */ + public static int findNearestBombDistance(int playerPos, boolean[] board) { + for (int i = playerPos; i < SIZE; i++) { + if (board[i]) { + return i; + } + } + return -1; + } + + /** + * Ends the game and displays the final message. + * + * @param message The final message to be displayed. + * @param roundsSurvived The number of rounds survived. + */ + public static void endGame(String message, int roundsSurvived) { + System.out.println(message); + System.out.println("You survived " + roundsSurvived + " rounds"); + int finalScore = calculateFinalScore(roundsSurvived); + System.out.println("Final Score: " + finalScore); + } + + /** + * Calculates the final score based on rounds survived and additional bonuses. + * + * @param roundsSurvived The number of rounds survived. + * @return The final calculated score. + */ + public static int calculateFinalScore(int roundsSurvived) { + int baseScore = 2 * roundsSurvived + score; + if (isWinningPosition(SIZE - 1, 0, new boolean[SIZE])) { + // If the player wins, add a bonus of 50 points + return baseScore + 50; + } else { + return baseScore; + } + } +} diff --git a/Code/multiply&Divide/.vscode/settings.json b/Code/multiply&Divide/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/multiply&Divide/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/multiply&Divide/README.md b/Code/multiply&Divide/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/multiply&Divide/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/multiply&Divide/bin/App.class b/Code/multiply&Divide/bin/App.class new file mode 100644 index 0000000..80fb602 Binary files /dev/null and b/Code/multiply&Divide/bin/App.class differ diff --git a/Code/multiply&Divide/src/App.java b/Code/multiply&Divide/src/App.java new file mode 100644 index 0000000..b8788a8 --- /dev/null +++ b/Code/multiply&Divide/src/App.java @@ -0,0 +1,73 @@ +import java.util.Scanner; + +public class App { + static Scanner scan = new Scanner(System.in); + + public static void main(String[] args) throws Exception { + + boolean loop = true; + + do { + System.out.println("Give me a number (with a decimal point if you have to)"); + double numberOne = scan.nextDouble(); + System.out.println("Give me another number (with a decimal point if you have to)"); + double numberTwo = scan.nextDouble(); + + System.out.println("1 multiply, 2 divide, -1 cancel"); + int userInput = scan.nextInt(); + + switch (userInput) { + case 1: + System.out.println(multiplyInput(numberOne, numberTwo)); + break; + case 2: + System.out.println(divideInput(numberOne, numberTwo)); + break; + case -1: + loop = false; + break; + default: + System.out.println(userInput + " is not a valid input"); + break; + } + + if (loop) { + System.out.println("Want to try others numbers? 1 yes 2 no"); + int continueInput = scan.nextInt(); + + switch (continueInput) { + case 1: + System.out.println("=========================="); + break; + case 2: + loop = false; + break; + case -1: + System.out.println("why would you enter that? EXTERMINATE"); + loop = false; + break; + default: + System.out.println("Invalid Input stopped code"); + loop = false; + break; + } + } + + } while (loop); + + } + + public static double divideInput(double numberOne, double numberTwo) { + if (numberTwo == 0 || numberTwo == -0) { + System.out.println("Error division by 0"); + return 0; + } else { + return numberOne / numberTwo; + } + } + + public static double multiplyInput(double numberOne, double numberTwo) { + return numberOne * numberTwo; + } + +} diff --git a/Code/numberToStar/.vscode/settings.json b/Code/numberToStar/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/numberToStar/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/numberToStar/README.md b/Code/numberToStar/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/numberToStar/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/numberToStar/bin/App.class b/Code/numberToStar/bin/App.class new file mode 100644 index 0000000..b9aa462 Binary files /dev/null and b/Code/numberToStar/bin/App.class differ diff --git a/Code/numberToStar/src/App.java b/Code/numberToStar/src/App.java new file mode 100644 index 0000000..6ad4e0e --- /dev/null +++ b/Code/numberToStar/src/App.java @@ -0,0 +1,41 @@ +import java.util.Scanner; + +public class App { + public static void main(String[] args) throws Exception { + Scanner scan = new Scanner(System.in); + + int minNumber = 0; + int maxNumber = 20; + int cancel = -1; + + System.out.println("Which char (if you feel funky even multiple) do you want to demonstrate the number?"); + String diagram = scan.nextLine(); + + do { + + System.out.println("Please enter a number from " + minNumber + " to " + maxNumber + " (enter " + cancel + + " to cancel)"); + int userInput = scan.nextInt(); + + if (userInput == cancel) { + System.out.println("Program canceled"); + break; + } + + if (userInput > maxNumber || userInput < minNumber) { + System.out.println("Invalid Input, self destruction activated"); + break; + } + + for (int i = 0; i < userInput; i++) { + System.out.print(diagram); + } + System.out.println(""); + + } while (true); + + System.out.println("Program ended"); + scan.close(); + + } +} diff --git a/Code/papToCode/.vscode/settings.json b/Code/papToCode/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/papToCode/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/papToCode/README.md b/Code/papToCode/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/papToCode/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/papToCode/bin/App.class b/Code/papToCode/bin/App.class new file mode 100644 index 0000000..6de940c Binary files /dev/null and b/Code/papToCode/bin/App.class differ diff --git a/Code/papToCode/src/App.java b/Code/papToCode/src/App.java new file mode 100644 index 0000000..a06cbc2 --- /dev/null +++ b/Code/papToCode/src/App.java @@ -0,0 +1,29 @@ +import java.util.Scanner; + +public class App { + static Scanner scan = new Scanner(System.in); + + public static void main(String[] args) throws Exception { + + System.out.println("What's thou name?"); + String name = scan.nextLine(); + System.out.println("On what year did you enter this hell hole"); + int year = scan.nextInt(); + System.out.println("How old are thou?"); + double age = scan.nextInt(); + + double controllAge = 2023 - year; + + if (age == controllAge) { + System.out.println("Dear " + name + " your math is on point"); + } else if (controllAge > age) { + System.out.println("either you didn't have your birthday this year or you made a mistake"); + } else { + System.out.println( + "If you're the doctor or any other form of time traveller everything is allright otherwise wtf?"); + } + + System.out.println("Do you want to buy alcohol (1 = yes 2 = no)"); + + } +} diff --git a/Code/playGround/.vscode/settings.json b/Code/playGround/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/playGround/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/playGround/README.md b/Code/playGround/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/playGround/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/playGround/bin/App.class b/Code/playGround/bin/App.class new file mode 100644 index 0000000..038c1d3 Binary files /dev/null and b/Code/playGround/bin/App.class differ diff --git a/Code/playGround/src/App.java b/Code/playGround/src/App.java new file mode 100644 index 0000000..ebeaff2 --- /dev/null +++ b/Code/playGround/src/App.java @@ -0,0 +1,12 @@ +public class App { + public static void main(String[] args) throws Exception { + System.out.println("Hello, World!"); + + int counter = 0; + for (int i = 0; i > 9; i++) { + counter++; + } + int resultat = counter; + System.out.println(resultat); + } +} diff --git a/Code/playGround24.1.24/.vscode/settings.json b/Code/playGround24.1.24/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/playGround24.1.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/playGround24.1.24/README.md b/Code/playGround24.1.24/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/playGround24.1.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/playGround24.1.24/bin/App.class b/Code/playGround24.1.24/bin/App.class new file mode 100644 index 0000000..baa6c67 Binary files /dev/null and b/Code/playGround24.1.24/bin/App.class differ diff --git a/Code/playGround24.1.24/src/App.java b/Code/playGround24.1.24/src/App.java new file mode 100644 index 0000000..0a839f9 --- /dev/null +++ b/Code/playGround24.1.24/src/App.java @@ -0,0 +1,5 @@ +public class App { + public static void main(String[] args) throws Exception { + System.out.println("Hello, World!"); + } +} diff --git a/Code/pleaseGodHaveMercy/.vscode/settings.json b/Code/pleaseGodHaveMercy/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/pleaseGodHaveMercy/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/pleaseGodHaveMercy/README.md b/Code/pleaseGodHaveMercy/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/pleaseGodHaveMercy/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/pleaseGodHaveMercy/bin/App.class b/Code/pleaseGodHaveMercy/bin/App.class new file mode 100644 index 0000000..806d45e Binary files /dev/null and b/Code/pleaseGodHaveMercy/bin/App.class differ diff --git a/Code/pleaseGodHaveMercy/src/App.java b/Code/pleaseGodHaveMercy/src/App.java new file mode 100644 index 0000000..40cbb3a --- /dev/null +++ b/Code/pleaseGodHaveMercy/src/App.java @@ -0,0 +1,50 @@ +public class App { + + public static void main(String[] args) { + calcFaculty(1, 15); + System.out.println(); + + calcFibonacci(20); + System.out.println(); + System.out.println(); + + calcSquareNumber(7, 34); + + } + + public static void calcFaculty(int low, int high) { + for (int i = low; i <= high; i++) { + int factorial = 1; + for (int j = 1; j <= i; j++) { + factorial *= j; + } + if (i < 10) { + System.out.println("Fakultät von 0" + i + " ist: " + factorial); + } else + System.out.println("Fakultät von " + i + " ist: " + factorial); + } + + } + + public static void calcFibonacci(int bound) { + int a = 0, b = 1, c; + System.out.println("Fibonacci-Reihe bis zum " + bound + ". Glied:"); + for (int i = 1; i <= bound; i++) { + System.out.print(a + " "); + c = a + b; + a = b; + b = c; + } + + } + + public static void calcSquareNumber(int low, int bound) { + System.out.println("Quadratzahlen von " + low + " bis " + bound + ":"); + for (int i = low; i <= bound; i++) { + if (i < 10) { + System.out.println("0" + i + " zum Quadrat ist: " + (i * i)); + } else + System.out.println(i + " zum Quadrat ist: " + (i * i)); + } + } +} \ No newline at end of file diff --git a/Code/randomRandomizerTask/.vscode/settings.json b/Code/randomRandomizerTask/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/randomRandomizerTask/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/randomRandomizerTask/README.md b/Code/randomRandomizerTask/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/randomRandomizerTask/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/randomRandomizerTask/bin/App.class b/Code/randomRandomizerTask/bin/App.class new file mode 100644 index 0000000..ec7c2bf Binary files /dev/null and b/Code/randomRandomizerTask/bin/App.class differ diff --git a/Code/randomRandomizerTask/src/App.java b/Code/randomRandomizerTask/src/App.java new file mode 100644 index 0000000..79c2c3a --- /dev/null +++ b/Code/randomRandomizerTask/src/App.java @@ -0,0 +1,45 @@ +import java.util.Random; + +public class App { + public static void main(String[] args) { + int totalSimulations = 1000000; + int countThirdDrawer = 0; + int moneyInDrawer = 0; + + Random random = new Random(); + + for (int i = 0; i < totalSimulations; i++) { + // Simulate whether the Euro is in the desk (50% probability) + boolean euroInDesk = random.nextBoolean(); + if (euroInDesk) + + // If the Euro is in the desk, it is equally likely to be in any drawer + if (euroInDesk) { + // Controll if it 50% + moneyInDrawer++; + // Simulate searching the drawers + int randomNumber = random.nextInt(3); + switch (randomNumber) { + + case 0: + break; + case 1: + break; + case 2: + countThirdDrawer++; + break; + default: + break; + } + } + } + + // Calculate the probability based on the simulation results + double probability = (double) countThirdDrawer / totalSimulations; + double probabilityCash = (double) moneyInDrawer / totalSimulations; + + System.out.println("Estimated Probability: " + (probability * 100) + "%"); + System.out.println("Estimated Probability for money: " + (probabilityCash * 100) + "%"); + + } +} diff --git a/Code/refacorinII/.vscode/settings.json b/Code/refacorinII/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/refacorinII/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/refacorinII/README.md b/Code/refacorinII/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/refacorinII/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/refacorinII/bin/App.class b/Code/refacorinII/bin/App.class new file mode 100644 index 0000000..2468ad7 Binary files /dev/null and b/Code/refacorinII/bin/App.class differ diff --git a/Code/refacorinII/src/App.java b/Code/refacorinII/src/App.java new file mode 100644 index 0000000..3cba79f --- /dev/null +++ b/Code/refacorinII/src/App.java @@ -0,0 +1,28 @@ +public class App { + + public static void main(String[] args) { + calcMathI(5, 1); + calcMathI(10, 2); + calcMathII(3, 5, 1); + calcMathII(7, 10, 1); + + } + + public static void calcMathI(int startValue, int step) { + + int sum = 0; + for (int i = 0; i < 10; i++) { + sum += startValue + (i * step); + } + System.out.println("Summe mit Startwert " + startValue + " und Schrittweite " + step + ": " + sum); + + } + + public static void calcMathII(int startValue, int endValue, int product) { + for (int i = startValue; i <= endValue; i++) { + product *= i; + } + System.out.println("Produkt von " + startValue + " bis " + endValue + ": " + product); + } + +} \ No newline at end of file diff --git a/Code/starSigns/.vscode/settings.json b/Code/starSigns/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/starSigns/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/starSigns/README.md b/Code/starSigns/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/starSigns/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/starSigns/bin/App.class b/Code/starSigns/bin/App.class new file mode 100644 index 0000000..bf96f7b Binary files /dev/null and b/Code/starSigns/bin/App.class differ diff --git a/Code/starSigns/src/App.java b/Code/starSigns/src/App.java new file mode 100644 index 0000000..94f74b8 --- /dev/null +++ b/Code/starSigns/src/App.java @@ -0,0 +1,138 @@ +import java.util.Scanner; + +public class App { + + public static void main(String[] args) throws Exception { + + while (true) { + // user Input birthday + int birthMonth = userInput("Your month"); + int birthDay = userInput("Your Birthday"); + // Is the date real + String + boolean validateDate = validateDate(birthDay, birthMonth); + if (validateDate) { + getStarSign(birthMonth, birthDay); + int userInput = userInput("Do you want to continue? 1 yes, 2 no"); + if (userInput == 2) { + break; + } + } else { + System.out.println("Invalid date please enter another one"); + System.out.println("******************************"); + } + } + } + + public static int userInput(String myText) { + Scanner scan = new Scanner(System.in); + System.out.println(myText); + return scan.nextInt(); + } + + public static void getStarSign(int month, int day) { + String starSign; + switch (month) { + case 1: + if (day <= 20) { + starSign = "Capricorn"; + } else { + starSign = "Aquarius"; + } + break; + case 2: + if (day <= 19) { + starSign = "Aquarius"; + } else { + starSign = "Pisces"; + } + break; + case 3: + if (day <= 20) { + starSign = "Pisces"; + } else { + starSign = "Aries"; + } + break; + case 4: + if (day <= 20) { + starSign = "Aries"; + } else { + starSign = "Taurus"; + } + break; + case 5: + if (day <= 21) { + starSign = "Taurus"; + } else { + starSign = "Gemini"; + } + break; + case 6: + if (day <= 21) { + starSign = "Gemini"; + } else { + starSign = "Cancer"; + } + break; + case 7: + if (day <= 22) { + starSign = "Cancer"; + } else { + starSign = "Leo"; + } + break; + case 8: + if (day <= 23) { + starSign = "Leo"; + } else { + starSign = "Virgo"; + } + break; + case 9: + if (day <= 23) { + starSign = "Virgo"; + } else { + starSign = "Libra"; + } + break; + case 10: + if (day <= 23) { + starSign = "Libra"; + } else { + starSign = "Scorpio"; + } + break; + case 11: + if (day <= 22) { + starSign = "Scorpio"; + } else { + starSign = "Sagittarius"; + } + break; + case 12: + if (day <= 21) { + starSign = "Sagittarius"; + } else { + starSign = "Capricorn"; + } + break; + default: + starSign = "Invalid month"; + } + + System.out.println("with the birthday " + day + ". " + month + " your assigned star sign is: " + starSign); + } + + public static boolean validateDate(int day, int month) { + switch (month) { + case 1, 3, 5, 7, 8, 10, 12: + return (day <= 31 && day > 0); + case 4, 6, 9, 11: + return (day <= 30 && day > 0); + case 2: + return (day <= 29 && day > 0); + default: + return false; + } + } +} diff --git a/Code/summeFuerArme/.vscode/settings.json b/Code/summeFuerArme/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/summeFuerArme/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/summeFuerArme/README.md b/Code/summeFuerArme/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/summeFuerArme/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/summeFuerArme/src/App.java b/Code/summeFuerArme/src/App.java new file mode 100644 index 0000000..1e4accf --- /dev/null +++ b/Code/summeFuerArme/src/App.java @@ -0,0 +1,69 @@ + + + // Variables + + int minRange = 0; + int maxRange = 1000; + int sum = 0; + int smallNumber = 0; + int bigNumber = 0; + boolean math = false; + + System.out.println("For random numbers, select 1, to define numbers press 2, to cancel press 3"); + int userInput = scan.nextInt(); + + switch (userInput) { + case 1: + // Generate two random numbers + math = true; + int random1 = random.nextInt(maxRange - minRange + 1) + minRange; + int random2 = random.nextInt(maxRange - minRange + 1) + minRange; + System.out.println("Random number 1: " + random1); + System.out.println("Random number 2: " + random2); + + // Calculate the sum of random numbers + for (int i = Math.min(random1, random2); i <= Math.max(random1, random2); i++) { + sum += i; + } + if (random1 > random2) { + bigNumber = random1; + smallNumber = random2; + } else { + bigNumber = random2; + smallNumber = random1; + } + break; + case 2: + math = true; + System.out.println("Enter the first number: "); + int numberOne = scan.nextInt(); + System.out.println("Enter the second number: "); + int numberTwo = scan.nextInt(); + + if (numberOne > numberTwo) { + bigNumber = numberOne; + smallNumber = numberTwo; + } else { + bigNumber = numberTwo; + smallNumber = numberOne; + } + + for (int i = smallNumber; i <= bigNumber; i++) { + sum += i; + } + break; + case 3: + System.out.println("Cancelled"); + break; + default: + System.out.println("Invalid choice"); + break; + } + + if (math) { + System.out.println("Sum of numbers between " + smallNumber + " and " + bigNumber + " is: " + sum); + } + + scan.close(); + } +} diff --git a/Code/swapArray/.vscode/settings.json b/Code/swapArray/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/swapArray/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/swapArray/README.md b/Code/swapArray/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/swapArray/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/swapArray/bin/App.class b/Code/swapArray/bin/App.class new file mode 100644 index 0000000..e6cff3c Binary files /dev/null and b/Code/swapArray/bin/App.class differ diff --git a/Code/swapArray/src/App.java b/Code/swapArray/src/App.java new file mode 100644 index 0000000..a44ea19 --- /dev/null +++ b/Code/swapArray/src/App.java @@ -0,0 +1,33 @@ +import java.util.Scanner; + +public class App { + public static void main(String[] args) { + String[] namen = { "Gian", "Leotrim", "Kevin", "Marco" }; + + print(namen); + swapArrayPosi(namen, 0, 4); + swapArrayPosi(namen, 1, 2); + + System.out.println("Print after the switch:"); + System.out.println("-----------------"); + + print(namen); + } + + public static void swapArrayPosi(String[] namen, int numberOne, int numberTwo) { + if (numberOne < 0 || numberOne >= namen.length || numberTwo < 0 || numberTwo >= namen.length) { + System.out.println("Error: Invalid indices for array swap."); + } else { + String placeholderString = namen[numberOne]; + namen[numberOne] = namen[numberTwo]; + namen[numberTwo] = placeholderString; + } + } + + public static void print(String[] namen) { + for (int i = 0; i < namen.length; i++) { + System.out.println(namen[i]); + } + } + +} diff --git a/Code/sysOutInput/.vscode/settings.json b/Code/sysOutInput/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/sysOutInput/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/sysOutInput/README.md b/Code/sysOutInput/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/sysOutInput/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/sysOutInput/bin/App.class b/Code/sysOutInput/bin/App.class new file mode 100644 index 0000000..093dedd Binary files /dev/null and b/Code/sysOutInput/bin/App.class differ diff --git a/Code/sysOutInput/src/App.java b/Code/sysOutInput/src/App.java new file mode 100644 index 0000000..af44300 --- /dev/null +++ b/Code/sysOutInput/src/App.java @@ -0,0 +1,17 @@ +import java.util.Scanner; + +public class App { + static Scanner scan = new Scanner(System.in); + + public static void main(String[] args) throws Exception { + String firstName = inputText("Give me your firstname"); + String lastName = inputText("Give me your lastname"); + System.out.println("Hallo " + firstName + " " + lastName + " prepare to die!"); + } + + public static String inputText(String input) { + System.out.println(input); + String output = scan.nextLine(); + return output; + } +} diff --git a/Code/test/.vscode/settings.json b/Code/test/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/test/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/test/README.md b/Code/test/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/test/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/test/bin/App.class b/Code/test/bin/App.class new file mode 100644 index 0000000..d5367e6 Binary files /dev/null and b/Code/test/bin/App.class differ diff --git a/Code/test/src/App.java b/Code/test/src/App.java new file mode 100644 index 0000000..8afc415 --- /dev/null +++ b/Code/test/src/App.java @@ -0,0 +1,12 @@ +public class App { + public static void main(String[] args) throws Exception { + int smallNumber = 3; + int bigNumber = 27; + int sum = 0; + + for (int i = smallNumber; i <= bigNumber; i++) { + sum = sum + i; + } + System.out.println(sum); + } +} diff --git a/Code/testModulo/.vscode/settings.json b/Code/testModulo/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/testModulo/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/testModulo/README.md b/Code/testModulo/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/testModulo/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/testModulo/bin/App.class b/Code/testModulo/bin/App.class new file mode 100644 index 0000000..f70c4c0 Binary files /dev/null and b/Code/testModulo/bin/App.class differ diff --git a/Code/testModulo/src/App.class b/Code/testModulo/src/App.class new file mode 100644 index 0000000..5b429aa Binary files /dev/null and b/Code/testModulo/src/App.class differ diff --git a/Code/testModulo/src/App.java b/Code/testModulo/src/App.java new file mode 100644 index 0000000..8de1984 --- /dev/null +++ b/Code/testModulo/src/App.java @@ -0,0 +1,5 @@ +public class App { + public static void main(String[] args) throws Exception { + System.out.println(2 % 3); + } +} diff --git a/Code/testTestTest/.vscode/settings.json b/Code/testTestTest/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/testTestTest/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/testTestTest/README.md b/Code/testTestTest/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/testTestTest/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/testTestTest/bin/App.class b/Code/testTestTest/bin/App.class new file mode 100644 index 0000000..ba081f6 Binary files /dev/null and b/Code/testTestTest/bin/App.class differ diff --git a/Code/testTestTest/src/App.java b/Code/testTestTest/src/App.java new file mode 100644 index 0000000..f0d6be8 --- /dev/null +++ b/Code/testTestTest/src/App.java @@ -0,0 +1,91 @@ +import java.util.Scanner; + +public class App { + static Scanner scan = new Scanner(System.in); + + public static void main(String[] args) throws Exception { + + boolean loop = true; + + do { + System.out.println("Give me a number (with a decimal point if you have to)"); + double numberOne = scan.nextDouble(); + System.out.println("Give me another number (with a decimal point if you have to)"); + double numberTwo = scan.nextDouble(); + + System.out.println("1 multiply, 2 divide, 3 sum, 4 bigger number, 5 average, 6 all -1 cancel"); + int userInput = scan.nextInt(); + + switch (userInput) { + case 1: + System.out.println("multiplacation: " + multiplyInput(numberOne, numberTwo)); + break; + case 2: + System.out.println("division: " + divideInput(numberOne, numberTwo)); + break; + case 3: + System.out.println("addition: " + addInput(numberOne, numberTwo)); + break; + case 4: + if (numberOne == numberTwo) { + System.out.println("The numbers are equal"); + break; + } else + System.out.println("bigger number: " + biggerNumber(numberOne, numberTwo)); + break; + case 5: + System.out.println("average: " + averageNumber(numberOne, numberTwo)); + case 6: + System.out.println("multiplacation: " + multiplyInput(numberOne, numberTwo)); + System.out.println("division: " + divideInput(numberOne, numberTwo)); + System.out.println("addition: " + addInput(numberOne, numberTwo)); + if (numberOne == numberTwo) { + System.out.println("The numbers are equal"); + break; + } else + System.out.println("bigger number: " + addInput(numberOne, numberTwo)); + System.out.println("sum: " + addInput(numberOne, numberTwo)); + case -1: + loop = false; + break; + default: + System.out.println(userInput + " is not a valid input"); + break; + } + } while (loop); + + } + + public static double divideInput(double numberOne, double numberTwo) { + if (numberTwo == 0 || numberTwo == -0) { + System.out.println("Error division by 0"); + return 0; + } else { + return numberOne / numberTwo; + } + } + + public static double multiplyInput(double numberOne, double numberTwo) { + return numberOne * numberTwo; + } + + public static double addInput(double numberOne, double numberTwo) { + return numberOne + numberTwo; + } + + public static double biggerNumber(double numberOne, double numberTwo) { + if (numberOne > numberTwo) { + return numberOne; + } else { + return numberTwo; + } + } + + public static double averageNumber(double numberOne, double numberTwo) { + return (numberOne + numberTwo) / 2; + } + + // public static double digitSum(double numberOne, double numberTwo) { + + // } +} diff --git a/Code/theMostBasicHash/.vscode/settings.json b/Code/theMostBasicHash/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/theMostBasicHash/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/theMostBasicHash/README.md b/Code/theMostBasicHash/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/theMostBasicHash/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/theMostBasicHash/bin/App.class b/Code/theMostBasicHash/bin/App.class new file mode 100644 index 0000000..0b48550 Binary files /dev/null and b/Code/theMostBasicHash/bin/App.class differ diff --git a/Code/theMostBasicHash/src/App.java b/Code/theMostBasicHash/src/App.java new file mode 100644 index 0000000..2d2b1ba --- /dev/null +++ b/Code/theMostBasicHash/src/App.java @@ -0,0 +1,58 @@ +import java.util.Scanner; + +public class App { + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + + System.out.println("Enter a message to encrypt:"); + String originalMessage = scanner.nextLine(); + + // Encrypt the message + System.out.println("Enter the encryption key (an integer):"); + int encryptionKey = scanner.nextInt(); + String encryptedMessage = encrypt(originalMessage, encryptionKey); + System.out.println("Encrypted message: " + encryptedMessage); + + // Decrypt the message + String decryptedMessage = decrypt(encryptedMessage, encryptionKey); + System.out.println("Decrypted message: " + decryptedMessage); + + scanner.close(); + } + + // Method to encrypt a message using Caesar cipher + private static String encrypt(String message, int key) { + StringBuilder encryptedText = new StringBuilder(); + + for (int i = 0; i < message.length(); i++) { + char currentChar = message.charAt(i); + + if (Character.isLetter(currentChar)) { + char encryptedChar = (char) ((currentChar - 'A' + key) % 26 + 'A'); + encryptedText.append(encryptedChar); + } else { + encryptedText.append(currentChar); + } + } + + return encryptedText.toString(); + } + + // Method to decrypt an encrypted message using Caesar cipher + private static String decrypt(String encryptedMessage, int key) { + StringBuilder decryptedText = new StringBuilder(); + + for (int i = 0; i < encryptedMessage.length(); i++) { + char currentChar = encryptedMessage.charAt(i); + + if (Character.isLetter(currentChar)) { + char decryptedChar = (char) ((currentChar - 'A' - key + 26) % 26 + 'A'); + decryptedText.append(decryptedChar); + } else { + decryptedText.append(currentChar); + } + } + + return decryptedText.toString(); + } +} diff --git a/Code/tiereGeräusche/.vscode/settings.json b/Code/tiereGeräusche/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/tiereGeräusche/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/tiereGeräusche/README.md b/Code/tiereGeräusche/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/tiereGeräusche/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/tiereGeräusche/bin/App.class b/Code/tiereGeräusche/bin/App.class new file mode 100644 index 0000000..7a22623 Binary files /dev/null and b/Code/tiereGeräusche/bin/App.class differ diff --git a/Code/tiereGeräusche/src/App.java b/Code/tiereGeräusche/src/App.java new file mode 100644 index 0000000..ca82f06 --- /dev/null +++ b/Code/tiereGeräusche/src/App.java @@ -0,0 +1,24 @@ +// Luca Burger +// Aufgabe 3 + +import java.util.Scanner; + +public class App { + static Scanner scan = new Scanner(System.in); + + public static void main(String[] args) throws Exception { + System.out.println("gib den namen eines Tieres ein"); + String tier = scan.nextLine(); + + if (tier.equalsIgnoreCase("Hund")) { + System.out.println("wuuuf"); + } else if (tier.equalsIgnoreCase("Kuh") || tier.equalsIgnoreCase("Stier")) { + System.out.println("muuuuuuuuuh"); + } else if (tier.equalsIgnoreCase("Katze")) { + System.out.println("miauuuuuuuu"); + } else { + System.out.println("unbekanntes Tier"); + } + scan.close(); + } +} \ No newline at end of file diff --git a/Code/uhrZeiten+++$/.vscode/settings.json b/Code/uhrZeiten+++$/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/uhrZeiten+++$/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/uhrZeiten+++$/README.md b/Code/uhrZeiten+++$/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/uhrZeiten+++$/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/uhrZeiten+++$/bin/App.class b/Code/uhrZeiten+++$/bin/App.class new file mode 100644 index 0000000..feb5bf8 Binary files /dev/null and b/Code/uhrZeiten+++$/bin/App.class differ diff --git a/Code/uhrZeiten+++$/src/App.java b/Code/uhrZeiten+++$/src/App.java new file mode 100644 index 0000000..9a0108a --- /dev/null +++ b/Code/uhrZeiten+++$/src/App.java @@ -0,0 +1,12 @@ +public class App { + public static void main(String[] args) throws Exception { + + for (int stunden = 0; stunden < 24; stunden++) { + for (int minuten = 0; minuten < 60; minuten += 15) { + + System.out.printf("%02d:%02d ", stunden, minuten); + + } + } + } +} diff --git a/Code/uhrZeiten++/.vscode/settings.json b/Code/uhrZeiten++/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/uhrZeiten++/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/uhrZeiten++/README.md b/Code/uhrZeiten++/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/uhrZeiten++/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/uhrZeiten++/bin/App.class b/Code/uhrZeiten++/bin/App.class new file mode 100644 index 0000000..597987c Binary files /dev/null and b/Code/uhrZeiten++/bin/App.class differ diff --git a/Code/uhrZeiten++/src/App.java b/Code/uhrZeiten++/src/App.java new file mode 100644 index 0000000..9e16d3b --- /dev/null +++ b/Code/uhrZeiten++/src/App.java @@ -0,0 +1,27 @@ +public class App { + public static void main(String[] args) throws Exception { + int stunden = 0; + int minuten = 0; + int sekunden = 0; + + while (true) { + sekunden += 30; + + if (sekunden == 60) { + minuten++; + sekunden = 0; + } + + if (minuten == 60) { + stunden++; + minuten = 0; + } + + if (stunden == 24) { + break; + } + + System.out.printf("%02d:%02d:%02d ", stunden, minuten, sekunden); + } + } +} diff --git a/Code/whileToFor/.vscode/settings.json b/Code/whileToFor/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/whileToFor/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/whileToFor/README.md b/Code/whileToFor/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/whileToFor/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/whileToFor/bin/App.class b/Code/whileToFor/bin/App.class new file mode 100644 index 0000000..59392a0 Binary files /dev/null and b/Code/whileToFor/bin/App.class differ diff --git a/Code/whileToFor/src/App.java b/Code/whileToFor/src/App.java new file mode 100644 index 0000000..896f4cf --- /dev/null +++ b/Code/whileToFor/src/App.java @@ -0,0 +1,17 @@ +import java.util.Scanner; + +public class App { + static Scanner scan = new Scanner(System.in); + + public static void main(String[] args) throws Exception { + int summe = 0; + + for (int x = 1; x < 3; x++) { + for (int y = x; y > 1; y--) { + summe += y; + } + } + + System.out.println(summe); + } +} diff --git a/Code/zeroOneNine/.vscode/settings.json b/Code/zeroOneNine/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/zeroOneNine/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/zeroOneNine/README.md b/Code/zeroOneNine/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/zeroOneNine/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/zeroOneNine/bin/App.class b/Code/zeroOneNine/bin/App.class new file mode 100644 index 0000000..c34e8bb Binary files /dev/null and b/Code/zeroOneNine/bin/App.class differ diff --git a/Code/zeroOneNine/src/App.java b/Code/zeroOneNine/src/App.java new file mode 100644 index 0000000..a929a1f --- /dev/null +++ b/Code/zeroOneNine/src/App.java @@ -0,0 +1,53 @@ +import java.util.Scanner; + +public class App { + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + + while (true) { + System.out.print("Enter a number between 0 and 9 (or -1 to exit): "); + int userInput = scanner.nextInt(); + + switch (userInput) { + case 0: + System.out.println("Your number is Zero"); + break; + case 1: + System.out.println("Your number is One"); + break; + case 2: + System.out.println("Your number is Two"); + break; + case 3: + System.out.println("Your number is Three"); + break; + case 4: + System.out.println("Your number is Four"); + break; + case 5: + System.out.println("Your number is Five"); + break; + case 6: + System.out.println("Your number is Six"); + break; + case 7: + System.out.println("Your number is Seven"); + break; + case 8: + System.out.println("Your number is Eight"); + break; + case 9: + System.out.println("Your number is Nine"); + break; + case -1: + System.out.println("Program terminated."); + scanner.close(); + System.exit(0); + default: + System.out.println("Invalid input. Program terminated."); + scanner.close(); + System.exit(0); + } + } + } +} diff --git a/MethodemBalckBoxTheorie.txt b/MethodemBalckBoxTheorie.txt new file mode 100644 index 0000000..27328cc --- /dev/null +++ b/MethodemBalckBoxTheorie.txt @@ -0,0 +1,32 @@ +Methodem: + +Var 1 -- Video: +video bearbeitung + +Input: +Roh Videos +Filter +Musik etc. + +Verabeitung: +Zusammenschnitt + +Output: +Fertiges Video + + +Var 2 -- RPG: + +Input: +Charackter +Angriff +Level + +Verabeitung: +Brechnung/randomizer +treffen? +schaden? +etc. + +Output: +Schaden oder keiner \ No newline at end of file diff --git a/Notizen/Casting.pptx b/Notizen/Casting.pptx new file mode 100644 index 0000000..c07967a Binary files /dev/null and b/Notizen/Casting.pptx differ diff --git a/Notizen/Datum.pap b/Notizen/Datum.pap new file mode 100644 index 0000000..a399cee --- /dev/null +++ b/Notizen/Datum.pap @@ -0,0 +1,280 @@ + + + + + + + + +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ = 1 && <= 31]]> +
+
+ +
+ =1 && <=12]]> +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ \ No newline at end of file diff --git a/Notizen/Gap text.txt b/Notizen/Gap text.txt new file mode 100644 index 0000000..4df347f --- /dev/null +++ b/Notizen/Gap text.txt @@ -0,0 +1,13 @@ +They where (A) throw a (B). +They're eyes where (C) as the (D). +They're hair as (E) as (F). +It was a (H) day, for after a long journey they finally found their (I). + +A=walking +B=Parkinglot +C=Blue +D=Sky +E=Black +G=Blackberrys +H=beatifull +I=lighter \ No newline at end of file diff --git a/Notizen/Geografie.pap b/Notizen/Geografie.pap new file mode 100644 index 0000000..e998ef9 --- /dev/null +++ b/Notizen/Geografie.pap @@ -0,0 +1,198 @@ + + + + + + + + +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ \ No newline at end of file diff --git a/Notizen/Methoden.pap b/Notizen/Methoden.pap new file mode 100644 index 0000000..d8a5cbf --- /dev/null +++ b/Notizen/Methoden.pap @@ -0,0 +1,80 @@ + + + + + + + + +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+
+ + + + + + +
+ + + + +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+
+ + + + +
+
+
+ \ No newline at end of file diff --git a/Notizen/Number sortring.pap b/Notizen/Number sortring.pap new file mode 100644 index 0000000..343872f --- /dev/null +++ b/Notizen/Number sortring.pap @@ -0,0 +1,117 @@ + + + + + + + + +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ myNumberTwo?]]> +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + +
+
+
+ \ No newline at end of file diff --git a/Notizen/Virus.pap b/Notizen/Virus.pap new file mode 100644 index 0000000..ad65ca9 --- /dev/null +++ b/Notizen/Virus.pap @@ -0,0 +1,120 @@ + + + + + + + + +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + +
+
+
+ \ No newline at end of file diff --git a/Notizen/Zahlen basisiss = N.txt b/Notizen/Zahlen basisiss = N.txt new file mode 100644 index 0000000..61b1404 --- /dev/null +++ b/Notizen/Zahlen basisiss = N.txt @@ -0,0 +1,41 @@ +Mathematische Anweisung (Kopf): + + +Zahlen basisiss = N +a-1=b +b-1=c +c-1=d + +Variable = 1 ; Stop +a = 55 + +a+b+c+d+e.....= Ergebniss + + +Mathematische Anweisung (Google): + + +(n × (n + 1))/2 + +Beispiel: + +(8 x (8 + 1) / 2 = 36 + + +sprachliche Anweisungen: + + +minimale zahl = x +maximale = y +Addiere alle ganzen Zahlen in dieser Spanne! + +Beispiel= + +x=1 +y=8 + +1+2+3+4+5+6+7+8=36 + + + + diff --git a/Notizen/alkohol.pap b/Notizen/alkohol.pap new file mode 100644 index 0000000..3ed088d --- /dev/null +++ b/Notizen/alkohol.pap @@ -0,0 +1,118 @@ + + + + + + + + +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ 100]]> +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ 16?]]> +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ 18?]]> +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + +
+
+
+ \ No newline at end of file diff --git a/Notizen/hpmssenbck-sprechen-sie-java-eine-einfhrung-in-das-systematische-programmieren_compress.pdf b/Notizen/hpmssenbck-sprechen-sie-java-eine-einfhrung-in-das-systematische-programmieren_compress.pdf new file mode 100644 index 0000000..45fc2f5 Binary files /dev/null and b/Notizen/hpmssenbck-sprechen-sie-java-eine-einfhrung-in-das-systematische-programmieren_compress.pdf differ diff --git a/Notizen/threeNumberSort.pap b/Notizen/threeNumberSort.pap new file mode 100644 index 0000000..cd366b9 --- /dev/null +++ b/Notizen/threeNumberSort.pap @@ -0,0 +1,180 @@ + + + + + + + + +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ zahl2?]]> +
+
+ +
+ +
+
+ +
+ Zahl 3?]]> +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ zahl3?]]> +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ \ No newline at end of file diff --git a/Notizen/wochenTage.pap b/Notizen/wochenTage.pap new file mode 100644 index 0000000..734d432 --- /dev/null +++ b/Notizen/wochenTage.pap @@ -0,0 +1,205 @@ + + + + + + + + +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ \ No newline at end of file diff --git a/Prüfungen/Aufgabe13/.vscode/settings.json b/Prüfungen/Aufgabe13/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Prüfungen/Aufgabe13/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Prüfungen/Aufgabe13/README.md b/Prüfungen/Aufgabe13/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Prüfungen/Aufgabe13/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/Prüfungen/Aufgabe13/bin/App.class b/Prüfungen/Aufgabe13/bin/App.class new file mode 100644 index 0000000..4b8f071 Binary files /dev/null and b/Prüfungen/Aufgabe13/bin/App.class differ diff --git a/Prüfungen/Aufgabe13/bin/App2.class b/Prüfungen/Aufgabe13/bin/App2.class new file mode 100644 index 0000000..19e8378 Binary files /dev/null and b/Prüfungen/Aufgabe13/bin/App2.class differ diff --git a/Prüfungen/Aufgabe13/bin/App3.class b/Prüfungen/Aufgabe13/bin/App3.class new file mode 100644 index 0000000..0d7ff97 Binary files /dev/null and b/Prüfungen/Aufgabe13/bin/App3.class differ diff --git a/Prüfungen/Aufgabe13/src/App.java b/Prüfungen/Aufgabe13/src/App.java new file mode 100644 index 0000000..5bbc8f3 --- /dev/null +++ b/Prüfungen/Aufgabe13/src/App.java @@ -0,0 +1,27 @@ +// Luca Fabian Burger +// Aufgabe 13 +// Die Eingabe von Fliesskomazahlen funktioniert nicht + +import java.util.Scanner; + +public class App { + static Scanner scan = new Scanner(System.in); + + public static void main(String[] args) { + + System.out.println("Was ist dein Vorname?"); + String vorname = scan.next(); + + System.out.println("Wie schwer sind Sie in KG? (mit Kommastellen)"); + double gewicht = scan.nextDouble(); + + System.out.println("Wie gross sind Sie in Meter (mit Kommastellen)"); + double groesse = scan.nextDouble(); + + double bmi = gewicht / (groesse * groesse); + + System.out.println("Lieber " + vorname + " dein BMI beträgt: " + bmi); + + scan.close(); + } +} diff --git a/Prüfungen/Aufgabe13/src/App2.java b/Prüfungen/Aufgabe13/src/App2.java new file mode 100644 index 0000000..4648735 --- /dev/null +++ b/Prüfungen/Aufgabe13/src/App2.java @@ -0,0 +1,16 @@ +// Luca Fabian Burger +// Aufgabe 14 + +public class App2 { + public static void main(String[] args) throws Exception { + double myFirstBottle = 5; + double mySecondBottle = 0; + double myThirdBottle = 0; + + mySecondBottle = myFirstBottle / 2; + myThirdBottle = myFirstBottle / 2; + System.out.println("Flasche 1: " + mySecondBottle); + System.out.println("Flasche 2: " + myThirdBottle); + + } +} \ No newline at end of file diff --git a/Prüfungen/Aufgabe13/src/App3.java b/Prüfungen/Aufgabe13/src/App3.java new file mode 100644 index 0000000..f4591c5 --- /dev/null +++ b/Prüfungen/Aufgabe13/src/App3.java @@ -0,0 +1,34 @@ + +// Luca Fabian Burger +// Aufgabe 15 + +import java.util.Scanner; + +public class App3 { + static Scanner scan = new Scanner(System.in); + + public static void main(String[] args) { + System.out.println("Erste Zahl"); + int zahl1 = scan.nextInt(); + System.out.println("Zweite Zahl"); + int zahl2 = scan.nextInt(); + System.out.println("Dritte Zahl"); + int zahl3 = scan.nextInt(); + System.out.println("Vierte Zahl"); + int zahl4 = scan.nextInt(); + System.out.println("Orginal: " + zahl1 + " " + zahl2 + " " + zahl3 + " " + zahl4); + + // Ab hier programmieren + int behaelter = 0; + + behaelter = zahl1; + zahl1 = zahl4; + zahl4 = behaelter; + behaelter = zahl2; + zahl2 = zahl3; + zahl3 = behaelter; + + // Bis hierhin programmieren + System.out.println("Umgekehrt: " + zahl1 + " " + zahl2 + " " + zahl3 + " " + zahl4); + } +} \ No newline at end of file diff --git a/bin/Archiv/Gaptext.class b/bin/Archiv/Gaptext.class deleted file mode 100644 index 8d1715a..0000000 Binary files a/bin/Archiv/Gaptext.class and /dev/null differ diff --git a/bin/Archiv/Yoda.class b/bin/Archiv/Yoda.class deleted file mode 100644 index 710eb51..0000000 Binary files a/bin/Archiv/Yoda.class and /dev/null differ diff --git a/bin/Archiv/exchange.class b/bin/Archiv/exchange.class deleted file mode 100644 index b6e01da..0000000 Binary files a/bin/Archiv/exchange.class and /dev/null differ diff --git a/bin/Grundlagen.class b/bin/Grundlagen.class deleted file mode 100644 index 4d2d259..0000000 Binary files a/bin/Grundlagen.class and /dev/null differ diff --git a/bin/Testcode.class b/bin/Testcode.class deleted file mode 100644 index d0a81bd..0000000 Binary files a/bin/Testcode.class and /dev/null differ diff --git a/src/Archiv/Gaptext.java b/src/Archiv/Gaptext.java deleted file mode 100644 index 8fccecc..0000000 --- a/src/Archiv/Gaptext.java +++ /dev/null @@ -1,46 +0,0 @@ -package Archiv; - -import javax.swing.JOptionPane; - -public class Gaptext { - public static void main(String[] args) { - // Lückentexte / kombination aus variablen, print und if/else - - // Popups mit User Input - String a = JOptionPane.showInputDialog("Please enter a verb (-ing):"); - String b = JOptionPane.showInputDialog("Please enter a location:"); - String c = JOptionPane.showInputDialog("Please enter a color:"); - String d = JOptionPane.showInputDialog("Please enter something that's that color:"); - String e = JOptionPane.showInputDialog("Please enter a diffrent color:"); - String f = JOptionPane.showInputDialog("Please enter something that's that color:"); - String g = JOptionPane.showInputDialog("Please enter an adjective:"); - String h = JOptionPane.showInputDialog("Please enter an object"); - - // Error message - - if (a == null || a.trim().isEmpty()) { - System.out.println("Missing word(s) or canceled."); - } else if (b == null || b.trim().isEmpty()) { - System.out.println("Missing word(s) or canceled."); - } else if (c == null || c.trim().isEmpty()) { - System.out.println("Missing word(s) or canceled."); - } else if (d == null || d.trim().isEmpty()) { - System.out.println("Missing word(s) or canceled."); - } else if (e == null || e.trim().isEmpty()) { - System.out.println("Missing word(s) or canceled."); - } else if (f == null || f.trim().isEmpty()) { - System.out.println("Missing word(s) or canceled."); - } else if (g == null || g.trim().isEmpty()) { - System.out.println("Missing word(s) or canceled."); - } else if (h == null || h.trim().isEmpty()) { - System.out.println("Missing word(s) or canceled."); - } else { - - // Lückentext mit variablen - - System.out.println("They where " + a + " throw (a) " + b + ". They're eyes where "); - System.out.println(c + " as (the) " + d + " They're hair as " + e + " as (the) " + f + "."); - System.out.println("It was a " + g + " day, after a long journey they finally found their " + h); - } - } -} \ No newline at end of file diff --git a/src/Archiv/Yoda.java b/src/Archiv/Yoda.java deleted file mode 100644 index 847cebd..0000000 --- a/src/Archiv/Yoda.java +++ /dev/null @@ -1,32 +0,0 @@ -package Archiv; - -import java.util.Random; - -public class Yoda { - public static void main(String[] args) { - // Print text - - System.out.println("A code request you have made,"); - System.out.println("Fear not, for I am here to aid."); - System.out.println("In Java, a language so grand,"); - System.out.println("I'll lend you a helping hand."); - - // Creating a Random object - Random random = new Random(); - - // Define the range for xx, yy and zz - int minRange = -10000; - int maxRange = 10000; - - // Generate random values for xx, zz and yy within the specified range - int xx = random.nextInt(maxRange - minRange + 1) + minRange; - int yy = random.nextInt(maxRange - minRange + 1) + minRange; - int zz = random.nextInt(maxRange - minRange + 1) + minRange; - - int sum = xx + yy + zz; - - System.out.println("The sum of " + xx + ", " + yy + " and " + zz + " is: " + sum); - - System.out.println("May the code be with you!"); - } -} \ No newline at end of file diff --git a/src/Grundlagen.java b/src/Grundlagen.java deleted file mode 100644 index 159765c..0000000 --- a/src/Grundlagen.java +++ /dev/null @@ -1,45 +0,0 @@ -public class Grundlagen { - public static void main(String[] args) { - - // Hello World - System.out.println("Hello World"); - - // Zahlen Variablen - int x = 99; - int y = 2; - x = x + 1; - x = x + y; - System.out.println(x); - - // Buchstaben Variablen - char myA = 'a'; - System.out.println(myA); - - // If & else - if (x > 101) { - System.out.println("Der Wert ist grösser als 101"); - } else { - System.out.println("Der Wert ist kleiner als 101"); - } - - // Iteration - int anzahlDurchgaenge = 1; - while (anzahlDurchgaenge <= 5) { - System.out.println("Durchgang nr. " + anzahlDurchgaenge); - anzahlDurchgaenge = anzahlDurchgaenge + 1; - } - - // Datentypen - byte myByte = 127; - short myShort = 300; - - // With float the f is necassary because java otherwise treats it as a double - // (simplified anwser) - double myDoubleValue = 34.568956; - float myFloatValue = 17.567f; - - // Constant always uppercase // Fixed Number - - final double PI = 3.141592876; - } -} \ No newline at end of file diff --git a/src/Testcode.java b/src/Testcode.java deleted file mode 100644 index 7a532fb..0000000 --- a/src/Testcode.java +++ /dev/null @@ -1,5 +0,0 @@ -public class Testcode { - public static void main(String[] args) { - - } -}