Polymorphism Demo : polymorphism « Class « Flash / Flex / ActionScript






Polymorphism Demo

 

  class UnpaidIntern extends Employee {

    override public function receivePayment():Number {
      return 0;
    }

  }

  class Manager extends Employee {
  
    override public function receivePayment():Number {
      return baseSalary*3;
    }

  }
  class Engineer extends Employee {

    override public function receivePayment():Number {
      return this.baseSalary*2;
  }

  }
  class Employee {

    internal var baseSalary:Number = 1000;

    public function receivePayment():Number {
      return this.baseSalary;
    }

  }

        








Related examples in the same category

1.Implementing Subclass Versions of Superclass Methods
2.If you want the toString( ) method of Subclass to return a different value, you'll need to override it in the subclass