-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathPetOwner.java
More file actions
58 lines (47 loc) · 1.27 KB
/
PetOwner.java
File metadata and controls
58 lines (47 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package io.zipcoder.pets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class PetOwner {
private String name;
private ArrayList<Pet> petList = new ArrayList<>();
private static Integer ID = 0;
//private Integer numberOfPets;
public PetOwner(String name, int numOfPets) {
this.name = name;
this.petList = new ArrayList<>();
for (int i = 0; i < numOfPets; i++) {
petList.add(new Dog("TEST DOG", 90));
}
}
public String getName() {
return name;
}
public void setNumberOfPets(Integer newNumOfPets) {
for (int i = 0; i < newNumOfPets; i++) {
petList.add(new Dog("TEST DOG", 80));
}
}
public int getNumberOfPets() {
return petList.size();
}
public void addPet(Pet pet) {
for(Pet element: petList){
if(element != pet){
element = pet;
break;
}
}
}
public Pet getPetById(Integer petId) {
for(Pet pet: petList){
System.out.println(pet.getId());
if(pet.getId() == petId){
return pet;
}
}
return null;
}
public void setPetName(Pet pet, String newPetName) {
}
}