fork download
  1. import java.util.Arrays;
  2. import java.util.List;
  3.  
  4. public class Main {
  5. public static void main(String[] args) throws Exception {
  6. List<Human> humans = Arrays.asList(new GenericHuman(), new BeautifulGirl(), new GenericHuman());
  7. for (Human human : humans) {
  8. if (human.isBeautifulGirl()) {
  9. System.out.println("美少女はうんこしません!");
  10. } else {
  11. ((GenericHuman)human).defecate();
  12. }
  13. }
  14. }
  15. }
  16.  
  17. interface Human {
  18. boolean isBeautifulGirl();
  19. }
  20.  
  21. class GenericHuman implements Human {
  22. @Override
  23. public boolean isBeautifulGirl() {
  24. return false;
  25. }
  26.  
  27. public final void defecate() {
  28. System.out.println("ぶりぶりー");
  29. }
  30. }
  31.  
  32. class BeautifulGirl implements Human {
  33. private GenericHuman genericHuman;
  34.  
  35. public BeautifulGirl() {
  36. this(new GenericHuman());
  37. }
  38.  
  39. public BeautifulGirl(GenericHuman genericHuman) {
  40. this.genericHuman = genericHuman;
  41. }
  42.  
  43. @Override
  44. public final boolean isBeautifulGirl() {
  45. return true;
  46. }
  47.  
  48. private void defecate() {
  49. genericHuman.defecate();
  50. }
  51. }
  52.  
Success #stdin #stdout 0.07s 381184KB
stdin
Standard input is empty
stdout
ぶりぶりー
美少女はうんこしません!
ぶりぶりー