public void ProduceerGeluid() { foreach (Dier dier in _dieren) { dier.MaakGeluid(); if (dier is Vogel) { Vogel gecasteVogel = dier as Vogel; gecasteVogel.Vlieg(); } else if (dier is Vis) { Vis gecasteVis = dier as Vis; gecasteVis.Zwem(); } else if (dier is Reptiel) { Reptiel gecasteKrokodil = dier as Reptiel; gecasteKrokodil.Kruip(); } else if (dier is Zoogdier) { Zoogdier gecasteZoogdier = (Zoogdier)dier; gecasteZoogdier.Stap(); } } }
public void LaatAlleZoogDierenBevallen() { foreach (Dier dier in _dieren) { if (dier is Zoogdier) { Zoogdier zoogdier = dier as Zoogdier; zoogdier.Beval(); } } }