Skip to content
Snippets Groups Projects
Commit c00a51ab authored by Peter Hertkorn's avatar Peter Hertkorn
Browse files

Basis für Entensimulator

parent c6a0a5bf
No related branches found
No related tags found
No related merge requests found
package entensimulator;
public abstract class Ente {
abstract void anzeigen();
public void fliegen() {
}
public void quaken() {
}
}
package entensimulator;
public class GummiEnte extends Ente {
public GummiEnte() {
super();
}
public void anzeigen() {
System.out.println("Ich bin eine Gummi-Ente");
}
}
package entensimulator;
public class LockEnte extends Ente {
public LockEnte() {
super();
}
public void anzeigen() {
System.out.println("Ich bin eine Lockente");
}
}
package entensimulator;
public class MiniEntenSimulator {
public static void main(String[] args) {
StockEnte stockente = new StockEnte();
MoorEnte moorente = new MoorEnte();
LockEnte lockente = new LockEnte();
GummiEnte gummientchen = new GummiEnte();
stockente.quaken();
stockente.fliegen();
moorente.quaken();
moorente.fliegen();
lockente.quaken();
lockente.fliegen();
gummientchen.quaken();
gummientchen.fliegen();
// Gummiente soll jetzt fliegen können
gummientchen.fliegen();
}
}
package entensimulator;
public class MoorEnte extends Ente {
public MoorEnte() {
super();
}
public void anzeigen() {
System.out.println("Ich bin eine echte Moorente");
}
}
package entensimulator;
public class StockEnte extends Ente {
public StockEnte() {
super();
}
public void anzeigen() {
System.out.println("Ich bin eine echte Stockente");
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment