Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

*** C Sharp*** Create a class called CabinetMaker that inherits from the Commiss

ID: 3593088 • Letter: #

Question

*** C Sharp***

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.

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.

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.

Explanation / Answer

CODE

Copyable code:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

class CommisionEmployee

{

private string firstName;

private string lastName;

private string socialsecuritynumber;

private double grossSale;

private double commissionRate;

public CommisionEmployee(string first,string last,string ssn,double grossSale, double commissionRate)

{

this.firstName = first;

this.lastName = last;

this.socialsecuritynumber = ssn;

this.grossSale = grossSale;

this.commissionRate = commissionRate;

}

//get methods

public double getGrossSale()

{

return grossSale;

}

public double getCommissionRate()

{

return commissionRate;

}

public string FirstName

{

get

{

return firstName;

}

}

public string LastName

{

get

{

return lastName;

}

}

public string SocialSecurityNumber

{

get

{

return socialsecuritynumber;

}

}

public double GrossSales

{

get

{

return grossSale;

}

set

{

if (value >= 0)

grossSale = value;

else

throw new ArgumentOutOfRangeException("GrossSales", value, "GrossSales must be >=0");

}

}

public double CommissionRate

{

get

{

return commissionRate;

}

set

{

if ((value > 0) && (value < 1))

commissionRate = value;

else

throw new ArgumentOutOfRangeException("CommissionRate", value, "CommissionRate must be >0 and <1");

}

}

public virtual double Earnings()

{

return commissionRate * grossSale;

}

public override string ToString()

{

return string.Format("{0}:{1} {2} {3}: {4} {5}: {6:C} {7}:{8:f2}", "commission employee", firstName, lastName, "social security number", socialsecuritynumber, "gross Sales", grossSale, "commission rate", commissionRate);

}

};

class CabinetMaker : CommisionEmployee

{

private string firstname;

private string lastname;

private string skillLevel;

//properties

public string SkillLevel

{

get { return skillLevel; }

set { skillLevel = value; }

}

//passing arguments to base class constructor

public CabinetMaker(double grossSale, double commissionRate, string sos,string first,string last, string skillLevel)

: base(first,last,sos,grossSale, commissionRate)

{

this.firstname = first;

this.lastname = last;

this.skillLevel = skillLevel;

}

public override double Earnings() //calculate earnings

{

if (SkillLevel == "experienced")

return (500 + getGrossSale() * getCommissionRate());

else if (SkillLevel == "apprentice")

return (250 + getGrossSale() * getCommissionRate());

else return 0;

}

};

namespace TestClass

{

class Program

{

static void Main(string[] args)

{

CabinetMaker carpenter1 = new CabinetMaker(5000, 0.32,"111", "John","san", "experienced");

Console.WriteLine("Earnings of carpenter 1 : $" + carpenter1.Earnings());

CabinetMaker carpenter2 = new CabinetMaker(5000, 0.32,"222", "John", "marco","apprentice");

Console.WriteLine("Earnings of carpenter 2 : $" + carpenter2.Earnings());

Console.ReadLine();

}

}

}

If any query regarding code please get back to me

Thank You