Bladeren bron

wriote starter main application

mpierse 8 jaren geleden
bovenliggende
commit
b93379321a

+ 19
- 1
src/main/java/io/zipcoder/polymorphism/MainApplication.java Bestand weergeven

@@ -1,7 +1,25 @@
1 1
 package io.zipcoder.polymorphism;
2
-
2
+import java.util.*;
3 3
 /**
4 4
  * Created by leon on 11/6/17.
5 5
  */
6 6
 public class MainApplication {
7
+
8
+    public static void main(String[] args) {
9
+    Scanner scn = new Scanner(System.in);
10
+    StringBuilder sb = new StringBuilder();
11
+    System.out.println("Hey there! How many pets do you have?");
12
+    int petNum = scn.nextInt();
13
+    System.out.println("That's cool. What's your first pet's name?");
14
+    String petName = scn.nextLine();
15
+    for (int i=1; i<=petNum; i++) {
16
+        petName = scn.nextLine();
17
+        sb.append(petName);
18
+
19
+        if (i<petNum){System.out.println("Aww! What's your next pet's name?");
20
+            sb.append(", ");}
21
+    }
22
+System.out.println("I like those pet names: ");
23
+System.out.print(sb.toString());
24
+}
7 25
 }

+ 1
- 0
src/test/java/io/zipcoder/polymorphism/MainApplicationTest.java Bestand weergeven

@@ -1,5 +1,6 @@
1 1
 package io.zipcoder.polymorphism;
2 2
 
3
+
3 4
 /**
4 5
  * Created by leon on 11/6/17.
5 6
  */

+ 4
- 0
src/test/java/io/zipcoder/polymorphism/Pet.java Bestand weergeven

@@ -0,0 +1,4 @@
1
+package io.zipcoder.polymorphism;
2
+
3
+public class Pet {
4
+}