|
@@ -3,8 +3,18 @@ import java.util.InputMismatchException;
|
3
|
3
|
import java.util.Arrays;
|
4
|
4
|
public class MainApplication {
|
5
|
5
|
|
|
6
|
+ private Pet pet;
|
|
7
|
+ private Pet[] petList;
|
6
|
8
|
|
|
9
|
+ public MainApplication(){
|
|
10
|
+ pet = new Pet();
|
|
11
|
+ }
|
|
12
|
+
|
7
|
13
|
public static void main(String[] args){
|
|
14
|
+
|
|
15
|
+ }
|
|
16
|
+
|
|
17
|
+ public void process(){
|
8
|
18
|
int pets;
|
9
|
19
|
System.out.println("How many pets do you have?");
|
10
|
20
|
pets = getNumberPets();
|
|
@@ -14,10 +24,10 @@ public class MainApplication {
|
14
|
24
|
System.out.println("These are all your pets: ");
|
15
|
25
|
System.out.println(Arrays.toString(listOfPets));
|
16
|
26
|
}
|
|
27
|
+ }
|
|
28
|
+
|
17
|
29
|
|
18
|
|
- }
|
19
|
|
-
|
20
|
|
- public static int getNumberPets(){
|
|
30
|
+ public int getNumberPets(){
|
21
|
31
|
int numberPets = 0;
|
22
|
32
|
Scanner input = new Scanner(System.in);
|
23
|
33
|
boolean error = true;
|
|
@@ -29,21 +39,23 @@ public class MainApplication {
|
29
|
39
|
input.next();
|
30
|
40
|
System.out.println("Error! Please type a number");
|
31
|
41
|
}
|
32
|
|
- } while (error);
|
33
|
|
- return numberPets;
|
|
42
|
+ } while (error);
|
|
43
|
+
|
|
44
|
+ pet.setPetNums(numberPets);
|
|
45
|
+ return pet.getPetNums();
|
34
|
46
|
}
|
35
|
47
|
|
36
|
|
- public static String setPetName(){
|
|
48
|
+ public String setPetName(){
|
37
|
49
|
Scanner input = new Scanner(System.in);
|
38
|
50
|
String petName = input.nextLine();
|
39
|
51
|
return petName;
|
40
|
52
|
}
|
41
|
53
|
|
42
|
|
- public static String[] makePetList(int numberOfPets){
|
43
|
|
- String[] petList = new String[numberOfPets];
|
|
54
|
+ public Pet[] makePetList(int numberOfPets){
|
|
55
|
+ petList = new Pet[numberOfPets];
|
44
|
56
|
for (int i = 0; i < petList.length; i++){
|
45
|
57
|
System.out.println("What is the name of pet number " + (i+1) + "?");
|
46
|
|
- petList[i] = setPetName();
|
|
58
|
+ petList[i] = pet.setName(setPetName());
|
47
|
59
|
}
|
48
|
60
|
|
49
|
61
|
return petList;
|