Mittwoch lesson

This commit is contained in:
sageTheDM 2024-12-19 07:51:04 +01:00
parent e0efeb82ef
commit 8901dea11b
61 changed files with 663 additions and 0 deletions

View file

@ -0,0 +1,3 @@
public abstract class Animal {
public abstract void makeSound();
}

View file

@ -0,0 +1,11 @@
public class Camel extends Animal implements Climbing {
@Override
public void makeSound() {
System.out.println("Desert Camel grumbles!");
}
@Override
public void climb() {
System.out.println("Desert Camel climbs a dune.");
}
}

View file

@ -0,0 +1,3 @@
public interface Climbing {
void climb();
}

View file

@ -0,0 +1,16 @@
public class Eagle extends Animal implements Flying, Swimming {
@Override
public void makeSound() {
System.out.println("Eagle screams!");
}
@Override
public void fly() {
System.out.println("Eagle flies high in the sky.");
}
@Override
public void swim() {
System.out.println("Eagle fishes in the water (swims...).");
}
}

View file

@ -0,0 +1,4 @@
public interface Flying {
void fly();
}

View file

@ -0,0 +1,16 @@
public class Frog extends Animal implements Swimming, Climbing {
@Override
public void makeSound() {
System.out.println("Green Frog croaks!");
}
@Override
public void swim() {
System.out.println("Green Frog swims in the pond.");
}
@Override
public void climb() {
System.out.println("Green Frog climbs a tree.");
}
}

View file

@ -0,0 +1,3 @@
public interface Swimming {
void swim();
}

View file

@ -0,0 +1,17 @@
public class ZooTest {
public static void main(String[] args) {
Animal eagle = new Eagle();
eagle.makeSound();
((Eagle) eagle).fly();
((Eagle) eagle).swim();
Animal frog = new Frog();
frog.makeSound();
((Frog) frog).swim();
((Frog) frog).climb();
Animal camel = new Camel();
camel.makeSound();
((Camel) camel).climb();
}
}