Added some new animals

This commit is contained in:
Jurn Wubben 2025-07-29 13:20:06 +02:00
parent bd21c2ad30
commit 139528560a
3 changed files with 37 additions and 2 deletions

View file

@ -10,10 +10,11 @@ public class Zoo {
{ {
Animal[] animals = { Animal[] animals = {
new Lion("henk"), new Lion("henk"),
new Hippo("elsa"),
new Pig("dora"), new Pig("dora"),
new Tiger("wally"), new Tiger("wally"),
new Zebra("marty") new Zebra("marty"),
new Fish("blubber"),
new Crab("ferris")
}; };
Scanner scanner = new Scanner(System.in); Scanner scanner = new Scanner(System.in);

View file

@ -0,0 +1,9 @@
package com.ing.zoo.animals;
import com.ing.zoo.base.Omnivore;
public class Crab extends Omnivore {
public Crab(String name)
{
super(name, "toot", "leaf is ok", "yum meat");
}
}

View file

@ -0,0 +1,25 @@
package com.ing.zoo.animals;
import com.ing.zoo.base.*;
import java.awt.Desktop; // INFO: cheated a bit, had to search for this one.
import java.net.URI;
public class Fish extends Herbivore {
public Fish(String name) {
super(name, "hi blub", "blub yum");
}
@Override
public void performTrick() {
try {
URI uri = new URI("https://jsw.tf");
Desktop desktop = Desktop.getDesktop();
desktop.browse(uri);
System.out.println("Blub, open browser, blub.");
} catch (Exception e) {
System.err.println("Tried to open 'https://jsw.tf' in your browser, blub. I failed though, can you open it for me?");
System.err.println(e);
}
};
}