-
-
Save Riduidel/a0cb4f411ed51b67b4f1b83343192f4b to your computer and use it in GitHub Desktop.
Visitor - 6 - visiteur avec StringBuilder
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
new Visitor<String>() { | |
StringBuilder returned = new StringBuilder(); | |
@Override public String visit(Feuille feuille) { | |
return returned.append(feuille.montrerFeuille()).append('\n').toString(); | |
} | |
@Override public String visit(Fleur fleur) { | |
return returned.append(fleur.afficherFleur()).append('\n').toString(); | |
} | |
@Override public void startVisit(Branche branche) { | |
returned.append("➡🌿").append('\n').toString(); | |
} | |
@Override public String endVisit(Branche branche) { | |
return returned.append("⬅🌿").append('\n').toString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment