// Fig. 10.8: BasePlusCommissionEmployee2.cs // BasePlusCommissionEmployee2 inherits from class CommissionEmployee. public class BasePlusCommissionEmployee2 : CommissionEmployee { private decimal baseSalary; // base salary per week // six-parameter derived class constructor // with call to base class CommissionEmployee constructor public BasePlusCommissionEmployee2( string first, string last, string ssn, decimal sales, decimal rate, decimal salary ) : base( first, last, ssn, sales, rate ) { BaseSalary = salary; // validate base salary via property } // end six-parameter BasePlusCommissionEmployee2 constructor // property that gets and sets // base-salaried commission employee's base salary public decimal BaseSalary { get { return baseSalary; } // end get set { baseSalary = ( value < 0 ) ? 0 : value; } // end set } // end property BaseSalary // calculate earnings public override decimal Earnings() { // not allowed: commissionRate and grossSales private in base class return baseSalary + ( commissionRate * grossSales ); } // end method Earnings // return string representation of BasePlusCommissionEmployee2 public override string ToString() { // not allowed: attempts to access private base class members return string.Format( "{0}: {1} {2}\n{3}: {4}\n{5}: {6:C}\n{7}: {8:F2}\n{9}: {10:C}", "base-salaried commission employee", firstName, lastName, "social security number", socialSecurityNumber, "gross sales", grossSales, "commission rate", commissionRate, "base salary", baseSalary ); } // end method ToString } // end class BasePlusCommissionEmployee2 /************************************************************************** * (C) Copyright 1992-2006 by Deitel & Associates, Inc. and * * Pearson Education, Inc. All Rights Reserved. * * * * DISCLAIMER: The authors and publisher of this book have used their * * best efforts in preparing the book. These efforts include the * * development, research, and testing of the theories and programs * * to determine their effectiveness. The authors and publisher make * * no warranty of any kind, expressed or implied, with regard to these * * programs or to the documentation contained in these books. The authors * * and publisher shall not be liable in any event for incidental or * * consequential damages in connection with, or arising out of, the * * furnishing, performance, or use of these programs. * *************************************************************************/