com.perisic.shadow.example.mains
Class Extend

java.lang.Object
  extended by com.perisic.shadow.example.mains.Extend

public class Extend
extends java.lang.Object

This example shows how a shadow can be used to to extend the functionality of a class. The class NiceFellow is shadowed by a CalamityShadow providing extra behaviour (tell calamity, crying). Note that the shadow also applies to the child NiceChild of NiceFellow. In addition we have shadowed the fabian object by a SmileShadow. Note that the SmileShadow has no effect on Tomislav's behaviour. This is the (uncommented) code of this class:

public class Extend {

 public static void main(String [] args) {
       NiceFellow.addShadow(NiceFellow.class, CalamityShadow.class);

       NiceFellow fabian = new NiceFellow("Fabian");
       NiceChild tomislav = new NiceChild("Tomislav");

       fabian.addShadow(new SmileShadow());
       fabian.call("smile",1);
       fabian.call("printMood"); 
       tomislav.call("printMood");

       System.out.println("");

       fabian.call("tellJokeTo", tomislav );
       tomislav.printMood();

       fabian.call("tellCalamityTo", tomislav );
       fabian.call("cry");
       tomislav.printMood();
       }


Constructor Summary
Extend()
           
 
Method Summary
static void main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Extend

public Extend()
Method Detail

main

public static void main(java.lang.String[] args)