Guest User

Untitled

a guest
Feb 4th, 2016
1,755
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.37 KB | None | 0 0
  1.     public static void main(String[] args){
  2.        
  3.         Animal sparky = new Dog();
  4.         Animal tweety = new Bird();
  5.        
  6.         System.out.println("Dog: " + sparky.tryToFly());
  7.        
  8.         System.out.println("Bird: " + tweety.tryToFly());
  9.        
  10.         // This allows dynamic changes for flyingType
  11.        
  12.         sparky.setFlyingAbility(new ItFlys());
  13.        
  14.         System.out.println("Dog: " + sparky.tryToFly());
  15.        
  16.     }
Advertisement
Add Comment
Please, Sign In to add comment