I don´t know why it was by default written in the Moveable interface, but it lead me to ask guys , whether there is static interfaces in java or not . I guess , we haven´t talked about that in previous lessons.
package de.codegym.task.task14.task1412;
/*
Die Methode printMainInfo implementieren
*/
public class Solution {
public static void main(String[] args) {
Object obj = new Circle();
Movable movable = (Movable) obj;
Drawable drawable = new Rectangle();
printMainInfo(drawable);
printMainInfo(movable);
}
public static void printMainInfo(Object object) {
//schreib hier deinen Code
if (object instanceof Drawable)
{
Drawable o1 = (Drawable) object ;
o1.draw();
}else if (object instanceof Moveable)
{
Moveable o2 = (Moveable) object;
o2.move();
}
static interface Movable {
void move();
}
static class Circle implements Movable {
public void draw() {
System.out.println("Kann gezogen werden");
}
public void move() {
System.out.println("Kann bewegt werden");
}
}
static interface Drawable {
void draw();
}
static class Rectangle implements Drawable {
public void draw() {
System.out.println("Kann gezogen werden");
}
public void move() {
System.out.println("Kann bewegt werden");
}
}
}