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