Added some new animals
This commit is contained in:
parent
bd21c2ad30
commit
139528560a
3 changed files with 37 additions and 2 deletions
|
|
@ -10,10 +10,11 @@ public class Zoo {
|
|||
{
|
||||
Animal[] animals = {
|
||||
new Lion("henk"),
|
||||
new Hippo("elsa"),
|
||||
new Pig("dora"),
|
||||
new Tiger("wally"),
|
||||
new Zebra("marty")
|
||||
new Zebra("marty"),
|
||||
new Fish("blubber"),
|
||||
new Crab("ferris")
|
||||
};
|
||||
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
|
|
|
|||
9
src/com/ing/zoo/animals/Crab.java
Normal file
9
src/com/ing/zoo/animals/Crab.java
Normal 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");
|
||||
}
|
||||
}
|
||||
25
src/com/ing/zoo/animals/Fish.java
Normal file
25
src/com/ing/zoo/animals/Fish.java
Normal 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);
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in a new issue