package DesignPatterns.Erzeugungsmuster_CreationalPatterns.Factory.Zoo.domain;

import java.lang.reflect.InvocationTargetException;

public abstract class Animal {
	private String name;
	private int alter;
	private String species;

	public Animal(String name, int alter) {
		this.name = name;
		this.alter = alter;
	}

	public abstract String speak();
	
	public String getSpecies() {
		return species;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getBirthyear() {
		return alter;
	}

	public void setBirthyear(int birthyear) {
		this.alter = birthyear;
	}

	public void setSpecies(String species) {
		this.species = species;
	}
	
	
	public static Animal erzeugeTier(String species ,String name, int alter) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, ClassNotFoundException {
		return (Animal) Class.forName(species)
				.getDeclaredConstructor(String.class, Integer.TYPE)
				.newInstance(name,alter);
	}
	

}