?
package de.codegym.task.task12.task1205;
/*
Tiere erkennen
*/
public class Solution {
public static void main(String[] args) {
System.out.println(getObjectType(new Cow()));
System.out.println(getObjectType(new Dog()));
System.out.println(getObjectType(new Whale()));
System.out.println(getObjectType(new Pig()));
}
public static String getObjectType(Object o) {
//schreib hier deinen Code
if (o instanceof Cow)
return "Kuh";
else if (o instanceof Dog)
return "Hund";
else if(o instanceof Whale)
return "Wal";
else
return "Unbekanntes Tier";
}
public static class Cow {
}
public static class Dog {
}
public static class Whale {
}
public static class Pig {
}
}