SlideShare a Scribd company logo
1 of 11
Download to read offline
Program.cs:
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Welcome the Employee Hierarchy Program");
Console.WriteLine("CIS247, Week 5 Lab");
Console.WriteLine("Name:
Solution
");
Console.WriteLine(" This program tests an Employee inheritance hierarchy ");
//Array to hold Employee type objects
Employee[] emp = new Employee[3];
//Initializing 3 values of array with 3 three types of classes
//Employee class object
emp[0] = new Employee("Joe", "Doe", 'M', 1, 10000.0, new Benefit("Partial", 1000, 2));
//Salaried Employee
emp[1] = new Salaried("Zoe", "Likoudis", 'F', 3, 20000.0, new Benefit("Full", 2000, 4), 1);
//Hourly Employee
emp[2] = new Hourly("Kate", "Perry", 'F', 0, 75, 25, new Benefit("Partial", 3000, 8), "part
time");
//Displaying their data to the console
for (int i = 0; i < emp.Length; i++)
{
Console.WriteLine(" ***************** Display Employee's Data ***************** ");
Console.WriteLine(emp[i].ToString());
}
//Displaying number of emps
Console.WriteLine(" Total number of employees in Database: {0} ",
Employee.GetNumberOfEmployees());
} //End of Main method
} //End of Program class
}//End of namespace
Employee.cs:
class Employee
{
//Private data members
protected string firstName;
protected string lastName;
protected char gender;
protected int dependents;
protected double annualSalary;
//Number of employees
private static int numEmployees = 0;
//Benefit object
protected Benefit benefit;
//Default Constructor
public Employee()
{
firstName = "not given";
lastName = "not given";
gender = 'U';
dependents = 0;
annualSalary = 20000;
//updates number of employees
numEmployees++;
benefit = new Benefit("not given", 0, 0);
}//End of Default Constructor
//Argumented Constructor
public Employee(string first, string last, char gen, int dep, double salary, Benefit benefit)
{
firstName = first;
lastName = last;
gender = gen;
dependents = dep;
annualSalary = salary;
//Updates number of employees
numEmployees++;
this.benefit = new Benefit(benefit.GetHealthInsurance(), benefit.GetLifeInsurance(),
benefit.GetVacation());
}//End of Argumented Constructor
//Calculates weekly pay
public virtual double CalculatePay()
{
return annualSalary / 52;
}//End of CalculatePay method
//Displays all the data of the employee
public override string ToString()
{
return string.Format("Employee Type : {0} First Name : {1} Last Name : {2} Gender : {3}
Dependents : {4} Annual Salary : {5:c} Weekly Pay : {6:c} {7}",
"GENERIC", FirstName, LastName, (Gender == 'M') ? "Male" : "Female", Dependents,
AnnualSalary, CalculatePay(), benefit.ToString());
}//End of DisplayEmployee method
//Public properties
//Property for first name of the employee
public string FirstName
{
set
{
firstName = value;
}
get
{
return firstName;
}
}//End of FirstName method
//Property for last name of the employee
public string LastName
{
set
{
lastName = value;
}
get
{
return lastName;
}
}//End of LastName method
//Gender of the employee
public char Gender
{
set
{
gender = value;
}
get
{
return gender;
}
}//End of Gender method
//The dependents
public int Dependents
{
set
{
dependents = value;
}
get
{
return dependents;
}
}//End of the Dependents method
//Annual salary
public double AnnualSalary
{
set
{
annualSalary = value;
}
get
{
return annualSalary;
}
}//End of AnnualSalary method
//Additional setter method for dependents
public void SetDependents(int dep)
{
dependents = dep;
}//End of SetDependents method
//Additional setter method for annual salary
public void SetAnnualSalary(double salary)
{
annualSalary = salary;
} //End of SetAnnualSalary method
//Returns number of employees created
public static int GetNumberOfEmployees()
{
return numEmployees;
}//End of GetNumberOfEmployees method
//Overloaded method of setDependents with string parameter
public void SetDependents(string dep)
{
dependents = Convert.ToInt32(dep);
}//End of SetDependents method
//Overloaded method of setAnnualSalary with string parameter
public void SetAnnualSalary(string salary)
{
annualSalary = Convert.ToDouble(salary);
}//End of SetAnnualSalary method
} //End of Employee class
}//End of namespace
Benefit.cs:
class Benefit
{
//Data fields
private string healthInsurance;
private double lifeInsurance;
private int vacation;
//Default constructor
public Benefit()
{
}//End of Default constructor
//Argumented constructor
public Benefit(string health, double life, int v)
{
healthInsurance = health;
lifeInsurance = life;
vacation = v;
}//End of Argumented constructor
//Displays the data of the object
public override string ToString()
{
return string.Format("Health Insurance: {0} Life Insurance : {1:c} Vacation : {2}",
healthInsurance, lifeInsurance, vacation);
}//End of ToString method
//Sets health insurance
public void SetHealthInsurance(string health)
{
healthInsurance = health;
}//End of SetHealthInsurance method
//Returns health insurance
public string GetHealthInsurance()
{
return healthInsurance;
}//End of GetHealthInsurance method
//sets life insurance
public void SetLifeInsurance(double life)
{
lifeInsurance = life;
}//End of SetLifeInsurance method
//Returns life insurance
public double GetLifeInsurance()
{
return lifeInsurance;
}//End of GetLifeInsurance method
//Sets vacation
public void SetVacation(int v)
{
vacation = v;
}//End of SetVacation method
//Returns vacation
public int GetVacation()
{
return vacation;
}//End of GetVacation method
}// End of Benefit class
}// End of namespace
Hourly.cs:
class Hourly : Employee
{
//Constant values for minimum, maximum wage and hours
private const double MIN_WAGE = 10;
private const double MAX_WAGE = 75;
private const double MIN_HOURS = 0;
private const double MAX_HOURS = 50;
private double wage; // wage of employee
private double hours; // hours worked
private string category; // category
//Noargument constructor
public Hourly()
: base()
{
wage = MIN_WAGE;
hours = MIN_HOURS;
category = "Not Given";
}//End of Noargument constructor.
//3-argument constructor
public Hourly(double wage, double hours, string category)
: base()
{
setWage(wage);
setHours(hours);
setCategory(category);
}//End of 3-Argument constructor
//8-argument cinstructor
public Hourly(string first, string last, char gen, int dep, double wage, double hours, Benefit ben,
string category)
: base(first, last, gen, dep, wage * 1300, ben)
{
setWage(wage);
setHours(hours);
setCategory(category);
}// End of 8-argument constructor
//Helper functions to set wage, hours and category
public void setWage(double wage)
{
if (wage >= MIN_WAGE && wage <= MAX_WAGE)
this.wage = wage;
else
this.wage = MIN_WAGE;
}//End of setWage
//Sets hours
public void setHours(double hours)
{
if (hours >= MIN_HOURS && hours <= MAX_HOURS)
this.hours = hours;
else
this.hours = MIN_HOURS;
}//End of setHours
//Sets category
public void setCategory(string category)
{
if (category == "temporary" || category == "part time" || category == "full time")
this.category = category;
else
this.category = "temporary";
}//End of setCategory
//Overrides the base class method calculatePay
public override double CalculatePay()
{
return wage * hours;
}//End of CalculatePay method
//Overrides the base class ToString to display data of the object
public override string ToString()
{
return string.Format("Employee Type : {0} First Name : {1} Last Name : {2} Gender : {3}
Dependents : {4} Category : {5} Wage : {6:c} Hours : {7} Weekly Pay : {8:c} Annual Salary :
{9:c} {10}",
GetType().Name.ToUpper(), FirstName, LastName, (Gender == 'M') ? "Male" : "Female",
Dependents, category, wage, hours, CalculatePay(), AnnualSalary, benefit.ToString());
}//End of ToString method
}//End of Hourly class
}//End of namespace
Salaried.cs:
class Salaried : Employee
{
//Constant values for minmum and maximum management levels
private const int MIN_MANAGEMENT_LEVEL = 0;
private const int MAX_MANAGEMENT_LEVEL = 3;
//Bonus percentage
private const double BONUS_PERCENT = 10.0;
//Employee management level
private int managementLevel;
//No argument constructor
public Salaried()
: base()
{
managementLevel = MIN_MANAGEMENT_LEVEL;
}
//7-ArgumentException constructor
public Salaried(string first, string last, char gen, int dep, double salary, Benefit benefit, int
manLevel)
: base(first, last, gen, dep, salary, benefit)
{
setManagementLevel(manLevel);
}
//2-Argument constructor
public Salaried(double salary, int manLevel)
: base()
{
AnnualSalary = salary;
setManagementLevel(manLevel);
}
//Helper method to set management level
public void setManagementLevel(int manLevel)
{
if (manLevel >= MIN_MANAGEMENT_LEVEL && manLevel <=
MAX_MANAGEMENT_LEVEL)
managementLevel = manLevel;
else
managementLevel = MIN_MANAGEMENT_LEVEL;
}//End of setManagementLevel method
//Overrides the base class method calculatePay
public override double CalculatePay()
{
double weekPay = AnnualSalary / 52;
return weekPay + weekPay * (managementLevel * BONUS_PERCENT / 100);
}//End of CalculatePay method
//Overrides the base class ToString to display data of the object
public override string ToString()
{
return string.Format("Employee Type : {0} First Name : {1} Last Name : {2} Gender : {3}
Dependents : {4} Management Lvl. : {5} Annual Salary : {6:c} Weekly Pay : {7:c} {8}",
GetType().Name.ToUpper(), FirstName, LastName, (Gender == 'M') ? "Male" : "Female",
Dependents, managementLevel, AnnualSalary, CalculatePay(), benefit.ToString());
}//End of ToString method
}//End of Salaried class
}//End of namespace

More Related Content

Similar to Program.cs class Program { static void Main(string[] args).pdf

Having issues with passing my values through different functions aft.pdf
Having issues with passing my values through different functions aft.pdfHaving issues with passing my values through different functions aft.pdf
Having issues with passing my values through different functions aft.pdfrajkumarm401
 
HELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdfHELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdffatoryoutlets
 
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docxINTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docxnormanibarber20063
 
Hi, I need help with a java programming project. specifically practi.pdf
Hi, I need help with a java programming project. specifically practi.pdfHi, I need help with a java programming project. specifically practi.pdf
Hi, I need help with a java programming project. specifically practi.pdffashioncollection2
 
in C++ Design a class named Employee The class should keep .pdf
in C++ Design a class named Employee The class should keep .pdfin C++ Design a class named Employee The class should keep .pdf
in C++ Design a class named Employee The class should keep .pdfadithyaups
 
Clean code in JavaScript
Clean code in JavaScriptClean code in JavaScript
Clean code in JavaScriptMathieu Breton
 
Introduction to ECMAScript 2015
Introduction to ECMAScript 2015Introduction to ECMAScript 2015
Introduction to ECMAScript 2015Tomasz Dziuda
 
Trace the following code to determine what will be outputted when Empl.pdf
Trace the following code to determine what will be outputted when Empl.pdfTrace the following code to determine what will be outputted when Empl.pdf
Trace the following code to determine what will be outputted when Empl.pdfaakriticollection61
 
Java questionI am having issues returning the score sort in numeri.pdf
Java questionI am having issues returning the score sort in numeri.pdfJava questionI am having issues returning the score sort in numeri.pdf
Java questionI am having issues returning the score sort in numeri.pdfforwardcom41
 
import java.io.-WPS Office.docx
import java.io.-WPS Office.docximport java.io.-WPS Office.docx
import java.io.-WPS Office.docxKatecate1
 
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDBTDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDBtdc-globalcode
 
In this assignment, you will continue working on your application..docx
In this assignment, you will continue working on your application..docxIn this assignment, you will continue working on your application..docx
In this assignment, you will continue working on your application..docxjaggernaoma
 
@author public class Person{   String sname, .pdf
  @author   public class Person{   String sname, .pdf  @author   public class Person{   String sname, .pdf
@author public class Person{   String sname, .pdfaplolomedicalstoremr
 
Django Admin: Widgetry & Witchery
Django Admin: Widgetry & WitcheryDjango Admin: Widgetry & Witchery
Django Admin: Widgetry & WitcheryPamela Fox
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For BeginnersJonathan Wage
 
TDC2016SP - Trilha .NET
TDC2016SP - Trilha .NETTDC2016SP - Trilha .NET
TDC2016SP - Trilha .NETtdc-globalcode
 
Can someone help me with this code When I run it, it stops after th.pdf
Can someone help me with this code When I run it, it stops after th.pdfCan someone help me with this code When I run it, it stops after th.pdf
Can someone help me with this code When I run it, it stops after th.pdfAmansupan
 

Similar to Program.cs class Program { static void Main(string[] args).pdf (20)

Having issues with passing my values through different functions aft.pdf
Having issues with passing my values through different functions aft.pdfHaving issues with passing my values through different functions aft.pdf
Having issues with passing my values through different functions aft.pdf
 
HELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdfHELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdf
 
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docxINTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
 
Hi, I need help with a java programming project. specifically practi.pdf
Hi, I need help with a java programming project. specifically practi.pdfHi, I need help with a java programming project. specifically practi.pdf
Hi, I need help with a java programming project. specifically practi.pdf
 
in C++ Design a class named Employee The class should keep .pdf
in C++ Design a class named Employee The class should keep .pdfin C++ Design a class named Employee The class should keep .pdf
in C++ Design a class named Employee The class should keep .pdf
 
Clean code in JavaScript
Clean code in JavaScriptClean code in JavaScript
Clean code in JavaScript
 
Introduction to ECMAScript 2015
Introduction to ECMAScript 2015Introduction to ECMAScript 2015
Introduction to ECMAScript 2015
 
Functional JS+ ES6.pptx
Functional JS+ ES6.pptxFunctional JS+ ES6.pptx
Functional JS+ ES6.pptx
 
Trace the following code to determine what will be outputted when Empl.pdf
Trace the following code to determine what will be outputted when Empl.pdfTrace the following code to determine what will be outputted when Empl.pdf
Trace the following code to determine what will be outputted when Empl.pdf
 
Java questionI am having issues returning the score sort in numeri.pdf
Java questionI am having issues returning the score sort in numeri.pdfJava questionI am having issues returning the score sort in numeri.pdf
Java questionI am having issues returning the score sort in numeri.pdf
 
import java.io.-WPS Office.docx
import java.io.-WPS Office.docximport java.io.-WPS Office.docx
import java.io.-WPS Office.docx
 
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDBTDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
 
In this assignment, you will continue working on your application..docx
In this assignment, you will continue working on your application..docxIn this assignment, you will continue working on your application..docx
In this assignment, you will continue working on your application..docx
 
@author public class Person{   String sname, .pdf
  @author   public class Person{   String sname, .pdf  @author   public class Person{   String sname, .pdf
@author public class Person{   String sname, .pdf
 
Class ‘increment’
Class ‘increment’Class ‘increment’
Class ‘increment’
 
Django Admin: Widgetry & Witchery
Django Admin: Widgetry & WitcheryDjango Admin: Widgetry & Witchery
Django Admin: Widgetry & Witchery
 
Intro to Ember.JS 2016
Intro to Ember.JS 2016Intro to Ember.JS 2016
Intro to Ember.JS 2016
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For Beginners
 
TDC2016SP - Trilha .NET
TDC2016SP - Trilha .NETTDC2016SP - Trilha .NET
TDC2016SP - Trilha .NET
 
Can someone help me with this code When I run it, it stops after th.pdf
Can someone help me with this code When I run it, it stops after th.pdfCan someone help me with this code When I run it, it stops after th.pdf
Can someone help me with this code When I run it, it stops after th.pdf
 

More from anandshingavi23

You need to provide the data for the 4 other meas.pdf
                     You need to provide the data for the 4 other meas.pdf                     You need to provide the data for the 4 other meas.pdf
You need to provide the data for the 4 other meas.pdfanandshingavi23
 
When an acid reacts with a base produces a salt &.pdf
                     When an acid reacts with a base produces a salt &.pdf                     When an acid reacts with a base produces a salt &.pdf
When an acid reacts with a base produces a salt &.pdfanandshingavi23
 
The one with the lowest Ksp will precipitate firs.pdf
                     The one with the lowest Ksp will precipitate firs.pdf                     The one with the lowest Ksp will precipitate firs.pdf
The one with the lowest Ksp will precipitate firs.pdfanandshingavi23
 
Riboflavin (Vitamin B2) consists of the sugar alc.pdf
                     Riboflavin (Vitamin B2) consists of the sugar alc.pdf                     Riboflavin (Vitamin B2) consists of the sugar alc.pdf
Riboflavin (Vitamin B2) consists of the sugar alc.pdfanandshingavi23
 
molar mass, or atomic weight, its true False. .pdf
                     molar mass, or atomic weight, its true    False. .pdf                     molar mass, or atomic weight, its true    False. .pdf
molar mass, or atomic weight, its true False. .pdfanandshingavi23
 
just multiply 806 by the molar mass of water and .pdf
                     just multiply 806 by the molar mass of water and .pdf                     just multiply 806 by the molar mass of water and .pdf
just multiply 806 by the molar mass of water and .pdfanandshingavi23
 
Image is not visible, kindly repost. .pdf
                     Image is not visible, kindly repost.             .pdf                     Image is not visible, kindly repost.             .pdf
Image is not visible, kindly repost. .pdfanandshingavi23
 
When it comes categorizing hazardous waste, the EPA has broken it do.pdf
When it comes categorizing hazardous waste, the EPA has broken it do.pdfWhen it comes categorizing hazardous waste, the EPA has broken it do.pdf
When it comes categorizing hazardous waste, the EPA has broken it do.pdfanandshingavi23
 
Visual hacking is used to visually capture private,sensitive informa.pdf
Visual hacking is used to visually capture private,sensitive informa.pdfVisual hacking is used to visually capture private,sensitive informa.pdf
Visual hacking is used to visually capture private,sensitive informa.pdfanandshingavi23
 
The standards used for the various layers in an Ethernet-based netwo.pdf
The standards used for the various layers in an Ethernet-based netwo.pdfThe standards used for the various layers in an Ethernet-based netwo.pdf
The standards used for the various layers in an Ethernet-based netwo.pdfanandshingavi23
 
The probability of at least one goal is P(X 1) = 1SolutionTh.pdf
The probability of at least one goal is P(X  1) = 1SolutionTh.pdfThe probability of at least one goal is P(X  1) = 1SolutionTh.pdf
The probability of at least one goal is P(X 1) = 1SolutionTh.pdfanandshingavi23
 
The end result of double fertilization is zygote and edosperm. In th.pdf
The end result of double fertilization is zygote and edosperm. In th.pdfThe end result of double fertilization is zygote and edosperm. In th.pdf
The end result of double fertilization is zygote and edosperm. In th.pdfanandshingavi23
 
The conus medullaris (Latin for medullary cone) is the tapered, .pdf
The conus medullaris (Latin for medullary cone) is the tapered, .pdfThe conus medullaris (Latin for medullary cone) is the tapered, .pdf
The conus medullaris (Latin for medullary cone) is the tapered, .pdfanandshingavi23
 
D is the answer take care .pdf
                     D is the answer  take care                       .pdf                     D is the answer  take care                       .pdf
D is the answer take care .pdfanandshingavi23
 
Endothermic or exothermic reaction nature .pdf
                     Endothermic or exothermic reaction nature        .pdf                     Endothermic or exothermic reaction nature        .pdf
Endothermic or exothermic reaction nature .pdfanandshingavi23
 
Step1 mass of 1 litre of sea water = 1.025x1000 =1025 g Step2 ma.pdf
Step1 mass of 1 litre of sea water = 1.025x1000 =1025 g Step2 ma.pdfStep1 mass of 1 litre of sea water = 1.025x1000 =1025 g Step2 ma.pdf
Step1 mass of 1 litre of sea water = 1.025x1000 =1025 g Step2 ma.pdfanandshingavi23
 
Solution66. Candida albicans is vaginal Yeast infection or “Thrus.pdf
Solution66. Candida albicans is vaginal Yeast infection or “Thrus.pdfSolution66. Candida albicans is vaginal Yeast infection or “Thrus.pdf
Solution66. Candida albicans is vaginal Yeast infection or “Thrus.pdfanandshingavi23
 
Rate of formation of P2O5=rate of reaction Rate of formation =2.9.pdf
Rate of formation of P2O5=rate of reaction Rate of formation =2.9.pdfRate of formation of P2O5=rate of reaction Rate of formation =2.9.pdf
Rate of formation of P2O5=rate of reaction Rate of formation =2.9.pdfanandshingavi23
 
Solution Lymphoid stem cell is a type of blood stem cells.These s.pdf
Solution Lymphoid stem cell is a type of blood stem cells.These s.pdfSolution Lymphoid stem cell is a type of blood stem cells.These s.pdf
Solution Lymphoid stem cell is a type of blood stem cells.These s.pdfanandshingavi23
 
copper sulphate when added to 5 moles of water ge.pdf
                     copper sulphate when added to 5 moles of water ge.pdf                     copper sulphate when added to 5 moles of water ge.pdf
copper sulphate when added to 5 moles of water ge.pdfanandshingavi23
 

More from anandshingavi23 (20)

You need to provide the data for the 4 other meas.pdf
                     You need to provide the data for the 4 other meas.pdf                     You need to provide the data for the 4 other meas.pdf
You need to provide the data for the 4 other meas.pdf
 
When an acid reacts with a base produces a salt &.pdf
                     When an acid reacts with a base produces a salt &.pdf                     When an acid reacts with a base produces a salt &.pdf
When an acid reacts with a base produces a salt &.pdf
 
The one with the lowest Ksp will precipitate firs.pdf
                     The one with the lowest Ksp will precipitate firs.pdf                     The one with the lowest Ksp will precipitate firs.pdf
The one with the lowest Ksp will precipitate firs.pdf
 
Riboflavin (Vitamin B2) consists of the sugar alc.pdf
                     Riboflavin (Vitamin B2) consists of the sugar alc.pdf                     Riboflavin (Vitamin B2) consists of the sugar alc.pdf
Riboflavin (Vitamin B2) consists of the sugar alc.pdf
 
molar mass, or atomic weight, its true False. .pdf
                     molar mass, or atomic weight, its true    False. .pdf                     molar mass, or atomic weight, its true    False. .pdf
molar mass, or atomic weight, its true False. .pdf
 
just multiply 806 by the molar mass of water and .pdf
                     just multiply 806 by the molar mass of water and .pdf                     just multiply 806 by the molar mass of water and .pdf
just multiply 806 by the molar mass of water and .pdf
 
Image is not visible, kindly repost. .pdf
                     Image is not visible, kindly repost.             .pdf                     Image is not visible, kindly repost.             .pdf
Image is not visible, kindly repost. .pdf
 
When it comes categorizing hazardous waste, the EPA has broken it do.pdf
When it comes categorizing hazardous waste, the EPA has broken it do.pdfWhen it comes categorizing hazardous waste, the EPA has broken it do.pdf
When it comes categorizing hazardous waste, the EPA has broken it do.pdf
 
Visual hacking is used to visually capture private,sensitive informa.pdf
Visual hacking is used to visually capture private,sensitive informa.pdfVisual hacking is used to visually capture private,sensitive informa.pdf
Visual hacking is used to visually capture private,sensitive informa.pdf
 
The standards used for the various layers in an Ethernet-based netwo.pdf
The standards used for the various layers in an Ethernet-based netwo.pdfThe standards used for the various layers in an Ethernet-based netwo.pdf
The standards used for the various layers in an Ethernet-based netwo.pdf
 
The probability of at least one goal is P(X 1) = 1SolutionTh.pdf
The probability of at least one goal is P(X  1) = 1SolutionTh.pdfThe probability of at least one goal is P(X  1) = 1SolutionTh.pdf
The probability of at least one goal is P(X 1) = 1SolutionTh.pdf
 
The end result of double fertilization is zygote and edosperm. In th.pdf
The end result of double fertilization is zygote and edosperm. In th.pdfThe end result of double fertilization is zygote and edosperm. In th.pdf
The end result of double fertilization is zygote and edosperm. In th.pdf
 
The conus medullaris (Latin for medullary cone) is the tapered, .pdf
The conus medullaris (Latin for medullary cone) is the tapered, .pdfThe conus medullaris (Latin for medullary cone) is the tapered, .pdf
The conus medullaris (Latin for medullary cone) is the tapered, .pdf
 
D is the answer take care .pdf
                     D is the answer  take care                       .pdf                     D is the answer  take care                       .pdf
D is the answer take care .pdf
 
Endothermic or exothermic reaction nature .pdf
                     Endothermic or exothermic reaction nature        .pdf                     Endothermic or exothermic reaction nature        .pdf
Endothermic or exothermic reaction nature .pdf
 
Step1 mass of 1 litre of sea water = 1.025x1000 =1025 g Step2 ma.pdf
Step1 mass of 1 litre of sea water = 1.025x1000 =1025 g Step2 ma.pdfStep1 mass of 1 litre of sea water = 1.025x1000 =1025 g Step2 ma.pdf
Step1 mass of 1 litre of sea water = 1.025x1000 =1025 g Step2 ma.pdf
 
Solution66. Candida albicans is vaginal Yeast infection or “Thrus.pdf
Solution66. Candida albicans is vaginal Yeast infection or “Thrus.pdfSolution66. Candida albicans is vaginal Yeast infection or “Thrus.pdf
Solution66. Candida albicans is vaginal Yeast infection or “Thrus.pdf
 
Rate of formation of P2O5=rate of reaction Rate of formation =2.9.pdf
Rate of formation of P2O5=rate of reaction Rate of formation =2.9.pdfRate of formation of P2O5=rate of reaction Rate of formation =2.9.pdf
Rate of formation of P2O5=rate of reaction Rate of formation =2.9.pdf
 
Solution Lymphoid stem cell is a type of blood stem cells.These s.pdf
Solution Lymphoid stem cell is a type of blood stem cells.These s.pdfSolution Lymphoid stem cell is a type of blood stem cells.These s.pdf
Solution Lymphoid stem cell is a type of blood stem cells.These s.pdf
 
copper sulphate when added to 5 moles of water ge.pdf
                     copper sulphate when added to 5 moles of water ge.pdf                     copper sulphate when added to 5 moles of water ge.pdf
copper sulphate when added to 5 moles of water ge.pdf
 

Recently uploaded

Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 

Recently uploaded (20)

Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 

Program.cs class Program { static void Main(string[] args).pdf

  • 1. Program.cs: class Program { static void Main(string[] args) { Console.WriteLine("Welcome the Employee Hierarchy Program"); Console.WriteLine("CIS247, Week 5 Lab"); Console.WriteLine("Name: Solution "); Console.WriteLine(" This program tests an Employee inheritance hierarchy "); //Array to hold Employee type objects Employee[] emp = new Employee[3]; //Initializing 3 values of array with 3 three types of classes //Employee class object emp[0] = new Employee("Joe", "Doe", 'M', 1, 10000.0, new Benefit("Partial", 1000, 2)); //Salaried Employee emp[1] = new Salaried("Zoe", "Likoudis", 'F', 3, 20000.0, new Benefit("Full", 2000, 4), 1); //Hourly Employee emp[2] = new Hourly("Kate", "Perry", 'F', 0, 75, 25, new Benefit("Partial", 3000, 8), "part time"); //Displaying their data to the console for (int i = 0; i < emp.Length; i++) { Console.WriteLine(" ***************** Display Employee's Data ***************** "); Console.WriteLine(emp[i].ToString()); } //Displaying number of emps Console.WriteLine(" Total number of employees in Database: {0} ", Employee.GetNumberOfEmployees()); } //End of Main method } //End of Program class }//End of namespace
  • 2. Employee.cs: class Employee { //Private data members protected string firstName; protected string lastName; protected char gender; protected int dependents; protected double annualSalary; //Number of employees private static int numEmployees = 0; //Benefit object protected Benefit benefit; //Default Constructor public Employee() { firstName = "not given"; lastName = "not given"; gender = 'U'; dependents = 0; annualSalary = 20000; //updates number of employees numEmployees++; benefit = new Benefit("not given", 0, 0); }//End of Default Constructor //Argumented Constructor public Employee(string first, string last, char gen, int dep, double salary, Benefit benefit) { firstName = first; lastName = last; gender = gen; dependents = dep; annualSalary = salary; //Updates number of employees numEmployees++; this.benefit = new Benefit(benefit.GetHealthInsurance(), benefit.GetLifeInsurance(),
  • 3. benefit.GetVacation()); }//End of Argumented Constructor //Calculates weekly pay public virtual double CalculatePay() { return annualSalary / 52; }//End of CalculatePay method //Displays all the data of the employee public override string ToString() { return string.Format("Employee Type : {0} First Name : {1} Last Name : {2} Gender : {3} Dependents : {4} Annual Salary : {5:c} Weekly Pay : {6:c} {7}", "GENERIC", FirstName, LastName, (Gender == 'M') ? "Male" : "Female", Dependents, AnnualSalary, CalculatePay(), benefit.ToString()); }//End of DisplayEmployee method //Public properties //Property for first name of the employee public string FirstName { set { firstName = value; } get { return firstName; } }//End of FirstName method //Property for last name of the employee public string LastName { set { lastName = value; } get
  • 4. { return lastName; } }//End of LastName method //Gender of the employee public char Gender { set { gender = value; } get { return gender; } }//End of Gender method //The dependents public int Dependents { set { dependents = value; } get { return dependents; } }//End of the Dependents method //Annual salary public double AnnualSalary { set { annualSalary = value; } get
  • 5. { return annualSalary; } }//End of AnnualSalary method //Additional setter method for dependents public void SetDependents(int dep) { dependents = dep; }//End of SetDependents method //Additional setter method for annual salary public void SetAnnualSalary(double salary) { annualSalary = salary; } //End of SetAnnualSalary method //Returns number of employees created public static int GetNumberOfEmployees() { return numEmployees; }//End of GetNumberOfEmployees method //Overloaded method of setDependents with string parameter public void SetDependents(string dep) { dependents = Convert.ToInt32(dep); }//End of SetDependents method //Overloaded method of setAnnualSalary with string parameter public void SetAnnualSalary(string salary) { annualSalary = Convert.ToDouble(salary); }//End of SetAnnualSalary method } //End of Employee class }//End of namespace Benefit.cs: class Benefit { //Data fields
  • 6. private string healthInsurance; private double lifeInsurance; private int vacation; //Default constructor public Benefit() { }//End of Default constructor //Argumented constructor public Benefit(string health, double life, int v) { healthInsurance = health; lifeInsurance = life; vacation = v; }//End of Argumented constructor //Displays the data of the object public override string ToString() { return string.Format("Health Insurance: {0} Life Insurance : {1:c} Vacation : {2}", healthInsurance, lifeInsurance, vacation); }//End of ToString method //Sets health insurance public void SetHealthInsurance(string health) { healthInsurance = health; }//End of SetHealthInsurance method //Returns health insurance public string GetHealthInsurance() { return healthInsurance; }//End of GetHealthInsurance method //sets life insurance public void SetLifeInsurance(double life) { lifeInsurance = life; }//End of SetLifeInsurance method //Returns life insurance
  • 7. public double GetLifeInsurance() { return lifeInsurance; }//End of GetLifeInsurance method //Sets vacation public void SetVacation(int v) { vacation = v; }//End of SetVacation method //Returns vacation public int GetVacation() { return vacation; }//End of GetVacation method }// End of Benefit class }// End of namespace Hourly.cs: class Hourly : Employee { //Constant values for minimum, maximum wage and hours private const double MIN_WAGE = 10; private const double MAX_WAGE = 75; private const double MIN_HOURS = 0; private const double MAX_HOURS = 50; private double wage; // wage of employee private double hours; // hours worked private string category; // category //Noargument constructor public Hourly() : base() { wage = MIN_WAGE; hours = MIN_HOURS; category = "Not Given"; }//End of Noargument constructor.
  • 8. //3-argument constructor public Hourly(double wage, double hours, string category) : base() { setWage(wage); setHours(hours); setCategory(category); }//End of 3-Argument constructor //8-argument cinstructor public Hourly(string first, string last, char gen, int dep, double wage, double hours, Benefit ben, string category) : base(first, last, gen, dep, wage * 1300, ben) { setWage(wage); setHours(hours); setCategory(category); }// End of 8-argument constructor //Helper functions to set wage, hours and category public void setWage(double wage) { if (wage >= MIN_WAGE && wage <= MAX_WAGE) this.wage = wage; else this.wage = MIN_WAGE; }//End of setWage //Sets hours public void setHours(double hours) { if (hours >= MIN_HOURS && hours <= MAX_HOURS) this.hours = hours; else this.hours = MIN_HOURS; }//End of setHours //Sets category public void setCategory(string category) {
  • 9. if (category == "temporary" || category == "part time" || category == "full time") this.category = category; else this.category = "temporary"; }//End of setCategory //Overrides the base class method calculatePay public override double CalculatePay() { return wage * hours; }//End of CalculatePay method //Overrides the base class ToString to display data of the object public override string ToString() { return string.Format("Employee Type : {0} First Name : {1} Last Name : {2} Gender : {3} Dependents : {4} Category : {5} Wage : {6:c} Hours : {7} Weekly Pay : {8:c} Annual Salary : {9:c} {10}", GetType().Name.ToUpper(), FirstName, LastName, (Gender == 'M') ? "Male" : "Female", Dependents, category, wage, hours, CalculatePay(), AnnualSalary, benefit.ToString()); }//End of ToString method }//End of Hourly class }//End of namespace Salaried.cs: class Salaried : Employee { //Constant values for minmum and maximum management levels private const int MIN_MANAGEMENT_LEVEL = 0; private const int MAX_MANAGEMENT_LEVEL = 3; //Bonus percentage private const double BONUS_PERCENT = 10.0; //Employee management level private int managementLevel; //No argument constructor public Salaried() : base() {
  • 10. managementLevel = MIN_MANAGEMENT_LEVEL; } //7-ArgumentException constructor public Salaried(string first, string last, char gen, int dep, double salary, Benefit benefit, int manLevel) : base(first, last, gen, dep, salary, benefit) { setManagementLevel(manLevel); } //2-Argument constructor public Salaried(double salary, int manLevel) : base() { AnnualSalary = salary; setManagementLevel(manLevel); } //Helper method to set management level public void setManagementLevel(int manLevel) { if (manLevel >= MIN_MANAGEMENT_LEVEL && manLevel <= MAX_MANAGEMENT_LEVEL) managementLevel = manLevel; else managementLevel = MIN_MANAGEMENT_LEVEL; }//End of setManagementLevel method //Overrides the base class method calculatePay public override double CalculatePay() { double weekPay = AnnualSalary / 52; return weekPay + weekPay * (managementLevel * BONUS_PERCENT / 100); }//End of CalculatePay method //Overrides the base class ToString to display data of the object public override string ToString() { return string.Format("Employee Type : {0} First Name : {1} Last Name : {2} Gender : {3} Dependents : {4} Management Lvl. : {5} Annual Salary : {6:c} Weekly Pay : {7:c} {8}",
  • 11. GetType().Name.ToUpper(), FirstName, LastName, (Gender == 'M') ? "Male" : "Female", Dependents, managementLevel, AnnualSalary, CalculatePay(), benefit.ToString()); }//End of ToString method }//End of Salaried class }//End of namespace