cleared the test code and transfeard data to Grundlagen
This commit is contained in:
		
							parent
							
								
									7cf18e66db
								
							
						
					
					
						commit
						3c0c934483
					
				
					 4 changed files with 32 additions and 66 deletions
				
			
		
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							|  | @ -1,3 +1,5 @@ | |||
| import java.util.Random; | ||||
| 
 | ||||
| import javax.swing.JOptionPane; | ||||
| 
 | ||||
| public class Grundlagen { | ||||
|  | @ -20,16 +22,16 @@ public class Grundlagen { | |||
|         if (x > 101) { | ||||
|             System.out.println("Der Wert ist grösser als 101"); | ||||
|         } else { | ||||
|             System.out.println("Der Wert ist kleiner als 101");   | ||||
|             System.out.println("Der Wert ist kleiner als 101"); | ||||
|         } | ||||
| 
 | ||||
|         // Iteration | ||||
|         int anzahlDurchgaenge = 1; | ||||
|         while(anzahlDurchgaenge <= 5) { | ||||
|         while (anzahlDurchgaenge <= 5) { | ||||
|             System.out.println("Durchgang nr. " + anzahlDurchgaenge); | ||||
|             anzahlDurchgaenge = anzahlDurchgaenge + 1; | ||||
|         } | ||||
|          | ||||
| 
 | ||||
|         // Lückentexte / kombination aus variablen, print und if/else | ||||
| 
 | ||||
|         // Popups mit User Input | ||||
|  | @ -43,7 +45,7 @@ public class Grundlagen { | |||
|         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()) { | ||||
|  | @ -68,5 +70,30 @@ public class Grundlagen { | |||
|             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!"); | ||||
|     } | ||||
| } | ||||
|  | @ -1,67 +1,6 @@ | |||
| import java.util.Random; | ||||
| 
 | ||||
| import javax.swing.JOptionPane; | ||||
| 
 | ||||
| public class Testcode { | ||||
|     public static void main(String[] args) { | ||||
|         | ||||
|         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 x, y and z | ||||
|         int minRange = -10000; | ||||
|         int maxRange = 10000; | ||||
| 
 | ||||
|         // Generate random values for x and y within the specified range | ||||
|         int x = random.nextInt(maxRange - minRange + 1) + minRange; | ||||
|         int y = random.nextInt(maxRange - minRange + 1) + minRange; | ||||
|         int z = random.nextInt(maxRange - minRange + 1) + minRange; | ||||
| 
 | ||||
|         int sum = x + y + z; | ||||
| 
 | ||||
|         System.out.println("The sum of " + x + ", " + y + " and " + z + " is: " + sum); | ||||
| 
 | ||||
|         System.out.println("May the code be with you!"); | ||||
|      | ||||
|         // Testing Inputs with a gap text | ||||
| 
 | ||||
|         // Display a popup dialog and get 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"); | ||||
| 
 | ||||
|         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 { | ||||
|             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); | ||||
|         } | ||||
|          | ||||
|     } | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Sage Burger
						Sage Burger