✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
Mis omadused on iseloomulikud Factory disainimustrile?
import java.util.List;
import java.util.ArrayList;
class Pet {
private static List<Pet> pets = new ArrayList<Pet>();
/*
Some other stuff...
*/
private Pet() {}
public static Pet getPet() {
if (pets.size() == 10) {
return null;
}
Pet p = new Pet();
pets.add(p);
return p;
}
}
Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!