Quellcode durchsuchen

revised loop edit

John Kim vor 6 Jahren
Ursprung
Commit
4962ee6dc1
3 geänderte Dateien mit 18 neuen und 12 gelöschten Zeilen
  1. BIN
      Main.class
  2. 11
    5
      Main.java
  3. 7
    7
      package.bluej

BIN
Main.class Datei anzeigen


+ 11
- 5
Main.java Datei anzeigen

6
 
6
 
7
     public static void main(String[] args ){
7
     public static void main(String[] args ){
8
         Scanner scanner = new Scanner(System.in);
8
         Scanner scanner = new Scanner(System.in);
9
-        System.out.println("What is your name?");
10
-        String name = scanner.nextLine();
11
-        if (name.equals("Alice") || name.equals("Bob")) {
12
-            System.out.println("Hello " + name + "!");
9
+        
10
+        while (true) {
11
+            
12
+            System.out.println("What is your name?");
13
+            String name = scanner.nextLine();
14
+            if (name.equals("Alice") || name.equals("Bob")) {
15
+                System.out.println("Hello " + name + "!");
16
+                break;
17
+            } else {
18
+                System.out.println("You're not Alice or Bob!");
19
+            }
13
         }
20
         }
14
-
15
     }
21
     }
16
 }
22
 }

+ 7
- 7
package.bluej Datei anzeigen

1
 #BlueJ package file
1
 #BlueJ package file
2
-editor.fx.0.height=0
3
-editor.fx.0.width=0
4
-editor.fx.0.x=0
5
-editor.fx.0.y=0
6
-objectbench.height=101
2
+editor.fx.0.height=722
3
+editor.fx.0.width=800
4
+editor.fx.0.x=250
5
+editor.fx.0.y=236
6
+objectbench.height=164
7
 objectbench.width=776
7
 objectbench.width=776
8
 package.divider.horizontal=0.6
8
 package.divider.horizontal=0.6
9
-package.divider.vertical=0.8007380073800738
10
-package.editor.height=427
9
+package.divider.vertical=0.6845018450184502
10
+package.editor.height=364
11
 package.editor.width=674
11
 package.editor.width=674
12
 package.editor.x=181
12
 package.editor.x=181
13
 package.editor.y=109
13
 package.editor.y=109