diff --git a/.vscode/settings.json b/.vscode/settings.json index e112a70..3652cd9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,5 +3,6 @@ "java.project.outputPath": "bin", "java.project.referencedLibraries": [ "lib/**/*.jar" - ] + ], + "java.format.settings.url": "eclipse-formatter.xml" } diff --git a/bin/Gaptext.class b/bin/Gaptext.class new file mode 100644 index 0000000..72f982e Binary files /dev/null and b/bin/Gaptext.class differ diff --git a/bin/Grundlagen.class b/bin/Grundlagen.class index 617f33b..e504b6f 100644 Binary files a/bin/Grundlagen.class and b/bin/Grundlagen.class differ diff --git a/bin/Testcode.class b/bin/Testcode.class index 3b8a146..d0a81bd 100644 Binary files a/bin/Testcode.class and b/bin/Testcode.class differ diff --git a/bin/Yoda.class b/bin/Yoda.class new file mode 100644 index 0000000..2625c2d Binary files /dev/null and b/bin/Yoda.class differ diff --git a/src/Gaptext.java b/src/Gaptext.java new file mode 100644 index 0000000..d80c575 --- /dev/null +++ b/src/Gaptext.java @@ -0,0 +1,46 @@ +import java.util.Random; + +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/Grundlagen.java b/src/Grundlagen.java index d6e5cbc..60aacd9 100644 --- a/src/Grundlagen.java +++ b/src/Grundlagen.java @@ -4,6 +4,7 @@ import javax.swing.JOptionPane; public class Grundlagen { public static void main(String[] args) { + // Hello World System.out.println("Hello World"); @@ -31,69 +32,5 @@ public class Grundlagen { System.out.println("Durchgang nr. " + anzahlDurchgaenge); anzahlDurchgaenge = anzahlDurchgaenge + 1; } - - // 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); - } - - // 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/Testcode.java b/src/Testcode.java index 6ae107d..7a532fb 100644 --- a/src/Testcode.java +++ b/src/Testcode.java @@ -1,6 +1,5 @@ public class Testcode { public static void main(String[] args) { - - + } } diff --git a/src/Yoda.java b/src/Yoda.java new file mode 100644 index 0000000..6dc76d1 --- /dev/null +++ b/src/Yoda.java @@ -0,0 +1,32 @@ +import java.util.Random; + +import javax.swing.JOptionPane; + +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