Last active
January 13, 2020 08:17
-
-
Save darrenbkl/a435a4ea97b6f4f14e3a33fb2b453985 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface Explorer { | |
void visit(Mercury mercury); | |
void visit(Mars mars); | |
void visit(Saturn saturn); | |
default void visit(Planet planet) { | |
System.out.println("Landed on an unknown planet..."); | |
} | |
} | |
public class LifeExplorer implements Explorer { | |
@Override | |
public void visit(Mercury mercury) { | |
System.out.println("Deploying tools specific to Mercury... exploring life"); | |
} | |
@Override | |
public void visit(Mars mars) { | |
System.out.println("Deploying tools specific to Mars... exploring life"); | |
} | |
@Override | |
public void visit(Saturn saturn) { | |
System.out.println("Deploying tools specific to Saturn... exploring life"); | |
} | |
@Override | |
public void visit(Planet planet) { | |
System.out.println("Cannot explore life on an unknown planet..."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment