// Managers need to know their number of stock options.
class Manager : Employee
{
private int numberOfOptions;
public int StockOptions
{
get { return numberOfOptions; }
set { numberOfOptions = value; }
}
}
Next, add another new class file (SalesPerson.cs) that defines the SalesPerson type:
// Salespeople need to know their number of sales.
class SalesPerson : Employee
{
private int numberOfSales;
public int SalesNumber
{
get { return numberOfSales; }
set { numberOfSales = value; }
}
}
Now that you have established an “is-a” relationship, SalesPerson and Manager have automati-
cally inherited all public members of the Employee base class. To illustrate, update your Main()
method as follows:
Do'stlaringiz bilan baham: |