-
-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5081958
commit cd2a84c
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
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
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) + "!!"); | ||
} | ||
} | ||
|
||
} |