// Fig. 10.14: BasePlusCommissionEmployee4.cs // BasePlusCommissionEmployee4 inherits from CommissionEmployee3 and has // access to CommissionEmployee3's private data via // its public properties. public class BasePlusCommissionEmployee4 : CommissionEmployee3 { private decimal baseSalary; // base salary per week // six-parameter derived class constructor // with call to base class CommissionEmployee3 constructor public BasePlusCommissionEmployee4( 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 BasePlusCommissionEmployee4 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() { return BaseSalary + base.Earnings(); } // end method Earnings // return string representation of BasePlusCommissionEmployee4 public override string ToString() { return string.Format( "{0} {1}\n{2}: {3:C}", "base-salaried", base.ToString(), "base salary", BaseSalary ); } // end method ToString } // end class BasePlusCommissionEmployee4 /************************************************************************** * (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. * *************************************************************************/