浏览代码

revised loop edit

John Kim 6 年前
父节点
当前提交
4962ee6dc1
共有 3 个文件被更改,包括 18 次插入12 次删除
  1. 二进制
      Main.class
  2. 11
    5
      Main.java
  3. 7
    7
      package.bluej

二进制
Main.class 查看文件


+ 11
- 5
Main.java 查看文件

@@ -6,11 +6,17 @@ public class Main {
6 6
 
7 7
     public static void main(String[] args ){
8 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 查看文件

@@ -1,13 +1,13 @@
1 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 7
 objectbench.width=776
8 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 11
 package.editor.width=674
12 12
 package.editor.x=181
13 13
 package.editor.y=109