AnimalFactory.java 520B

12345678910111213141516171819
  1. import java.util.Date;
  2. /**
  3. * @author leon on 4/19/18.
  4. * This class is responsible for creating animals and automatically assigning them an id
  5. */
  6. public class AnimalFactory {
  7. public static Dog createDog(String name, Date birthDate) {
  8. Integer newId = DogHouse.getNumberOfDogs();
  9. return new Dog(name, birthDate, newId);
  10. }
  11. public static Cat createCat(String name, Date birthDate) {
  12. Integer newId = CatHouse.getNumberOfCats();
  13. return new Cat(name, birthDate, newId);
  14. }
  15. }