Copy void main () {
// Polymorphism
Employee e1 = Developer ( 10 );
Employee e2 = Developer ( 20 );
Employee e3 = Manager ( 30 );
Employee e4 = Manager ( 40 );
List < Employee > organization = [e1,e2,e3,e4];
for ( var employee in organization) {
print (employee. salary ( 20 ));
}
}
class Employee {
int dayworked;
int salary ( int perDaywage) {
return (this.dayworked * perDaywage);
}
Employee (this.dayworked);
}
// Developer Class
class Developer extends Employee {
@override
int salary ( int perDaywage){
return (this.dayworked * perDaywage + 80 );
}
Developer ( int dayworked) : super(dayworked);
}
// Manager Class
class Manager extends Employee {
@override
int salary ( int perDaywage){
return (this.dayworked * perDaywage + 30 );
}
Manager ( int dayworked) : super(dayworked);
}
Diagram Reasoning behind the name
Copy void main () {
// Polymorphism => Polymorphic argument
int calsalary ( Employee employee){
return employee. salary ( 20 );
}
print ( calsalary ( Manager ( 10 )));
}
class Employee {
int dayworked;
int salary ( int perDaywage) {
return (this.dayworked * perDaywage);
}
Employee (this.dayworked);
}
// Developer Class
class Developer extends Employee {
@override
int salary ( int perDaywage){
return (this.dayworked * perDaywage + 80 );
}
Developer ( int dayworked) : super(dayworked);
}
// Manager Class
class Manager extends Employee {
@override
int salary ( int perDaywage){
return (this.dayworked * perDaywage + 30 );
}
Manager ( int dayworked) : super(dayworked);
}