Skip to content

Commit

Permalink
add Kanoonsantikul.java (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
kanoonsantikul authored Oct 9, 2022
1 parent 5081958 commit cd2a84c
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Java/Kanoonsantikul.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import java.util.List;

public class Kanoonsantikul {

private static class Person {
public String eat(Object input) {
return "Poop";
}
}

private static class Programmer extends Person {
@Override
public String eat(Object input) {
if (input.getClass().getSimpleName().equals("Coffee")) {
return "Code";
} else {
return super.eat(input);
}
}
}

private static class Coffee {}

public static void main(String[] args) {
Programmer bob = new Programmer();
List<Object> menuList = List.of("0xDEADBEEF", false, 100_000_000, new Coffee());
for (Object menu : menuList) {
System.out.println("What happen if programmer eat " + menu.getClass().getSimpleName());
System.out.println("It is " + bob.eat(menu) + "!!");
}
}

}

0 comments on commit cd2a84c

Please sign in to comment.