daily pastebin goal
10%
SHARE
TWEET

Untitled

hehasmoxie Oct 12th, 2017 164 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Create a class called CabinetMaker that inherits from the CommissionEmployee class in Figure 11.10 In your CabinetMaker class, Earnings() should  calculate the fee earned for a carpentry job.  Gross sales represents the amount charged to a customer and commission rate represents the % that a particular carpenter earns.   CabinetMaker Earnings is calculated as the skill level base rate + amount charged * commission rate.  Skill level base rate is $500 for a experienced carpenter and $250 for an apprentice.
  2. Your class should contain a constructor that inherits from the CommissionEmployee class and initializes the instance variables. The CabinetMaker class should add an instance variable for the name of the customer where the carpentry service occurred.   Also add an instance variable to represent skill level. Create a property for them also.
  3. Create a second class that prompts the user for the information for two carpenters, creates the 2 two carpenters objects, then displays each two carpenters.  One carpenter should be experienced and one should be an apprentice.
  4.  
  5. using System;
  6.  
  7. public class BasePlusCommissionEmployee : CommissionEmployee
  8. {
  9.     private decimal baseSalary;
  10.  
  11.  
  12.     public BasePlusCommissionEmployee( string firstName, string lastName,
  13.         string socialsecurityNumber, decimal grossSales, decimal commissionRate, decimal salary )
  14.         : base( firstName, lastName, socialsecurityNumber, grossSales, commissionRate )
  15.     {
  16.         BaseSalary = salary;
  17.     }
  18.  
  19.     public decimal BaseSalary
  20.     {
  21.         get
  22.         {
  23.             return baseSalary;
  24.         }
  25.         set
  26.         {
  27.             if (value >= 0)
  28.                 baseSalary = value;
  29.             else
  30.                 throw new ArgumentOutOfRangeException("BaseSalary",
  31.                     value, "BaseSalary must be >= 0");
  32.         }
  33.     }
  34.     public override decimal Earnings()
  35.     {
  36.         return baseSalary + (commissionRate * grossSales);
  37.     }
  38.  
  39.     public override string ToString()
  40.     {
  41.         return string.Format(
  42.             "{0}: {1} {2}\n{3}: {4}\n{5}: {6:C}\n{7}: {8:F2}\n{9}: {10:C}",
  43.             "base-salaried commission employee", firstName, lastName,
  44.             "social security number", socialSecurityNumber,
  45.             "gross sales", grossSales, "commission rate", commissionRate,
  46.             "base salary", baseSalary);
  47.     }
  48. }
  49. class CommissionEmployee
  50. {
  51.     private decimal commissionRate;
  52.     private string firstName;
  53.     private string lastName;
  54.     private decimal sales;
  55.     private string ssn;
  56.  
  57.     public CommissionEmployee(string firstName, string lastName, string ssn, decimal sales, decimal commissionRate)
  58.     {
  59.         this.firstName = firstName;
  60.         this.lastName = lastName;
  61.         this.ssn = ssn;
  62.         this.sales = sales;
  63.         this.commissionRate = commissionRate;
  64.     }
  65. }
  66. class CabinetMaker : CommissionEmployee
  67.     {
  68.         private decimal baseSalary;
  69.         public CabinetMaker(string firstName, string lastName, string socialsecurityNumber, decimal grossSales, decimal commissionRate, decimal salary) : base(firstName, lastName, socialsecurityNumber, grossSales, commissionRate)
  70.         {
  71.             BaseSalary = salary;
  72.         }
  73.         public decimal BaseSalary
  74.         {
  75.             get
  76.             {
  77.                 return baseSalary;
  78.             }
  79.             set
  80.             {
  81.                 if (value >= 0)
  82.                 {
  83.                     baseSalary = value;
  84.                else
  85.                    throw new ArgumentOutOfRangeException("BaseSalary", value, "BaseSalary must be >=0")
  86.                 }
  87.             }
  88.         }
  89.     }
  90.     public override decimal Earnings()
  91.  
  92.     {
  93.         return baseSalary + (commissionRate * grossSales);
  94.     }
  95.     public override string ToString()
  96.  
  97.     {
  98.         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);
  99.     }
RAW Paste Data
Top