浏览代码

greeting for alice and bob

Margaret Pierse 6 年前
父节点
当前提交
c76430a53c
共有 4 个文件被更改,包括 29 次插入9 次删除
  1. 二进制
      Greeting.class
  2. 7
    0
      Greeting.ctxt
  3. 22
    0
      Greeting.java
  4. 0
    9
      Main.java

二进制
Greeting.class 查看文件


+ 7
- 0
Greeting.ctxt 查看文件

@@ -0,0 +1,7 @@
1
+#BlueJ class context
2
+comment0.target=Greeting
3
+comment1.params=args
4
+comment1.target=void\ main(java.lang.String[])
5
+comment2.params=
6
+comment2.target=void\ sayHi()
7
+numComments=3

+ 22
- 0
Greeting.java 查看文件

@@ -0,0 +1,22 @@
1
+/**
2
+ * Created by iyasuwatts on 10/17/17.
3
+ */
4
+import java.util.*;
5
+public class Greeting {
6
+
7
+    public static void main(String[] args ){
8
+    }
9
+    public void sayHi(){ 
10
+        Scanner wordTyped = new Scanner(System.in);
11
+        System.out.println("What is your name");
12
+        String name = wordTyped.nextLine();
13
+        if (name.equals("Alice")) {
14
+            System.out.println("Hi Alice!");
15
+        } else if (name.equals("Bob")){
16
+            System.out.println("Hi Bob!");
17
+        } else {
18
+            System.out.println("Go away, this program is only for Alice and Bob!");
19
+        }
20
+
21
+    }
22
+}

+ 0
- 9
Main.java 查看文件

@@ -1,9 +0,0 @@
1
-/**
2
- * Created by iyasuwatts on 10/17/17.
3
- */
4
-public class Main {
5
-
6
-    public static void main(String[] args ){
7
-
8
-    }
9
-}