Tested the gaptext and used data for Grundlagen

This commit is contained in:
Sage Burger 2023-08-20 20:20:11 +02:00
parent bb2efe0de5
commit 735fd61747
4 changed files with 47 additions and 2 deletions

BIN
bin/Grundlagen.class Normal file

Binary file not shown.

Binary file not shown.

View file

@ -1,3 +1,5 @@
import javax.swing.JOptionPane;
public class Grundlagen { public class Grundlagen {
public static void main(String[] args) { public static void main(String[] args) {
// Hello World // Hello World
@ -27,5 +29,47 @@ public class Grundlagen {
System.out.println("Durchgang nr. " + anzahlDurchgaenge); System.out.println("Durchgang nr. " + anzahlDurchgaenge);
anzahlDurchgaenge = anzahlDurchgaenge + 1; anzahlDurchgaenge = anzahlDurchgaenge + 1;
} }
// Lückentexte / kombination aus variablen, print und if/else
// Display a popup dialog and get user input
// 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 an object in that color:");
String e = JOptionPane.showInputDialog("Please enter a diffrent color:");
String f = JOptionPane.showInputDialog("Please enter an object in 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()) && (b == null || b.trim().isEmpty())) {
System.out.println("Missing word(s) or canceled.");
} else 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 " + f + ".");
System.out.println("It was a " + g + " day, after a long journey they finally found their " + h);
}
} }
} }

View file

@ -4,6 +4,7 @@ import javax.swing.JOptionPane;
public class Testcode { public class Testcode {
public static void main(String[] args) { public static void main(String[] args) {
System.out.println("A code request you have made,"); System.out.println("A code request you have made,");
System.out.println("Fear not, for I am here to aid."); System.out.println("Fear not, for I am here to aid.");
System.out.println("In Java, a language so grand,"); System.out.println("In Java, a language so grand,");
@ -23,13 +24,13 @@ public class Testcode {
int sum = x + y + z; int sum = x + y + z;
System.out.println("The sum of " + x + " " + y + " and " + z + " is: " + sum); System.out.println("The sum of " + x + ", " + y + " and " + z + " is: " + sum);
System.out.println("May the code be with you!"); System.out.println("May the code be with you!");
// Testing Inputs with a gap text // Testing Inputs with a gap text
// Display a popup dialog and get user input // Display a popup dialog and get user input
String a = JOptionPane.showInputDialog("Please enter a verb (-ing):"); String a = JOptionPane.showInputDialog("Please enter a verb (-ing):");
String b = JOptionPane.showInputDialog("Please enter a location:"); String b = JOptionPane.showInputDialog("Please enter a location:");
String c = JOptionPane.showInputDialog("Please enter a color:"); String c = JOptionPane.showInputDialog("Please enter a color:");