Ver código fonte

greeting for alice and bob

Margaret Pierse 6 anos atrás
pai
commit
c76430a53c
4 arquivos alterados com 29 adições e 9 exclusões
  1. BIN
      Greeting.class
  2. 7
    0
      Greeting.ctxt
  3. 22
    0
      Greeting.java
  4. 0
    9
      Main.java

BIN
Greeting.class Ver arquivo


+ 7
- 0
Greeting.ctxt Ver arquivo

@@ -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 Ver arquivo

@@ -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 Ver arquivo

@@ -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
-}