Advertisement
Guest User

Untitled

a guest
May 24th, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. class Animal {
  2. public abstract class bark();
  3. }
  4.  
  5. class Tiger extends Animal {
  6. public class bark() {
  7.  
  8. }
  9. }
  10. class Lion extends Animal {
  11. public class bark() {
  12.  
  13. }
  14. }
  15.  
  16. public class Bouncer {
  17. public void barkAnimal(Animal animal) {
  18. if (animal instanceof Tiger) {
  19. System.out.println("어흥");
  20. } else if (animal instanceof Lion) {
  21. System.out.println("으르렁");
  22. }
  23. }
  24.  
  25. public static void main(String[] args) {
  26. Tiger tiger = new Tiger();
  27. Lion lion = new Lion();
  28.  
  29. Bouncer bouncer= new Bouncer();
  30. bouncer.barkAnimal(tiger);
  31. bouncer.barkAnimal(lion);
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement