6.5. The Third Pillar of OOP: C#'s Polymorphic Support
Recall that the Employee base class defined a method named GiveBonus(), which was originally implemented as follows:
public partial class Employee { public void GiveBonus(float amount) { currPay += amount; } ... }
Because this method has been defined with the public keyword, you can now give bonuses to salespeople and managers (as well as part-time salespeople):
static void Main(string[] args) { Console.WriteLine("***** The Employee Class Hierarchy *****\n"); // Give each employee a bonus? Manager chucky = new Manager("Chucky", 50, 92, 100000, "333-23-2322", 9000); chucky.GiveBonus(300); chucky.DisplayStats(); Console.WriteLine(); SalesPerson fran = new SalesPerson("Fran", 43, 93, 3000, ...
Get Pro C# 2010 and the .NET 4 Platform, Fifth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.