Friday, March 27, 2009

How polymorphism works on actionscript

Question :How polymorphism works on actionscript?
Answer :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;
}
}

No comments: