I need my code modified to do the following: Scenario and Summary The objective
ID: 3645312 • Letter: I
Question
I need my code modified to do the following:Scenario and Summary
The objective of the lab is to take the UML Class diagram and enhance last week's Employee class by making the following changes:
Convert the Employee class to an abstract class
Add an abstract method called CalculateNetPay to the Employee class
In both the Salaried and Hourly classes implement the CalculateNetPay method
Deliverables
Due this week:
Capture the Console output window and paste into a Word Document.
Zip the project folder.
Put the zip file and screenshots (word document) in the drop box.
i L A B S T E P S
STEP 1: Understand the UML Diagram
Analyze and understand the object UML diagram, which models the structure of the program.
The Employee class has been specifed as abstract, which is denoted by the name of the class being italized Employee
The Employee class as a new method CalculateNetPay which is an abstract method, denoted by the italized name of the method. Since this method is an abstract method the CalculateNetPay method WILL NOT have an implementation in the Employee class.
The Salaried and Hourly classes both have a new method CalculateNetPay that is inherited from the abstract Employee class and the Salaried and Hourly class both MUST implement the CalculateNetPay method.
STEP 2: Create the Project
You will want to use the Week 5 project as the starting point for the lab. Use the directions from the previous weeks labs to create the project and the folders.
Create a new project named "CIS247_WK4_Lab_LASTNAME". An empty project will then be created.
Delete the default Program.cs file that is created.
Add the Logic Tier, Presentation Tier, and Utilities folders to your proejct
Add the Week 5 project files to the appropraties folders.
Update the program information in the ApplicationUtilities.DisplayApplicationInformation method to reflect your name, current lab, and program description.
Note: as an alternative you can open up the Week 5 project and make modifications to the existing project. Remember, there is a copy of your project in the zip file you submitted for grading.
Before attempting this week's steps ensure that the Week 5 project is error free.
STEP 3: Modify the Employee Class
Modify the class declaration of the Employee class to specify that the Employee class is an abstract class
Declare an abstract method called CalculateNetPay that returns a double value.
Modify the ToString Method to include the weekly net pay in currency format.
STEP 4: Modify the Salaried Class
Add a double constant called TAX_RATE and set the value to .73
Implement the CalculateNetPay method by multiplying the weekly pay by the tax rate.
STEP 5: Modify the Hourly Class
Add a double constant called TAX_RATE and set the value to .82
Implement the CalculateNetPay method by multiplying the weekly pay by the tax rate.
STEP 6: Create the Main Program
Change the employeeList array to only hold two objects
Create one Hourly employee object and store it in the array.
Create one Salaried employee object and store it in the array.
As you did in the Week 5 lab, prompt for and collect the information for each of the objects.
Note: iterating through the array should not require any changes from the previous iteration of the project--but make sure that the loop stays within the bounds of the array.
STEP 7: Compile and Test
When done, compile and run your program.
Then debug any errors until your code is error-free.
Check your output to ensure that you have the desired output and modify your code as necessary and rebuild.
The output of your program should resemble the following:
On-screen output display:
Welcome the Employee Hierarchy Program
CIS247, Week 5 Lab
Name: Solution
This program tests an Employee inheritance hierarchy
*********************** Display Employee's Data ********************** Employee Type
Hourly
First Name
Mary
Last Name
Noia
Dependents
4
Annual Salary
$100,000
Weekly Pay
$2,080.00
Net Pay
$1,705.00
Health Insurance
Blue Cross
Life Insurance
$175,000
Vacation
24
Hours 40
Wage 52
Category Full Time
*********************** Display Employee's Data **********************
Employee Type
Salaried
First Name
Sue
Last Name
Smith
Gender
Female
Dependents
2
Annual Salary
$100,000.00
Weekly Pay
$2,500.00
Net Pay
$1,855.00
Health Insurance
Blue Cross
Life Insurance
$300,000
Vacation
15
Level 3
total Number of Employess in Database: 2
Press the ESC key to close the image description and return to lecture.
Image Description
My code is below...
Employee.cs
class Employee
{
// Attributes
protected const string DEFAULT_NAME = "NOT GIVEN";
protected const char DEFAULT_GENDER = 'U';
protected const int MIN_DEPENDENTS = 0;
protected const int MAX_DEPENDENTS = 10;
protected const double MIN_SALARY = 0;
protected const double MAX_SALARY = 200000;
protected string firstName = DEFAULT_NAME;
protected string lastName = DEFAULT_NAME;
protected char gender = DEFAULT_GENDER;
protected int dependents = 0;
protected double annualSalary = 2000;
protected static int numEmployees = 0;
protected string employeeType;
protected Benefits benefit;
// Methods
public static int NumEmployees
{
get { return numEmployees; }
}
public string EmployeeType
{
get { return employeeType; }
}
public int Dependents
{
get { return dependents;}
set
{
if (value > MAX_DEPENDENTS)
dependents = MAX_DEPENDENTS;
else
if (value < MIN_DEPENDENTS)
dependents = MIN_DEPENDENTS;
else
dependents = value;
}
}
public string FirstName
{
get { return firstName; }
set
{
if (String.IsNullOrEmpty(value))
firstName = DEFAULT_NAME;
else
firstName = value;
}
}
public string LastName
{
get { return lastName; }
set
{
if (String.IsNullOrEmpty(value))
lastName = DEFAULT_NAME;
else
lastName = value;
}
}
public char Gender
{
get { return gender; }
set
{
if(value == 'm' || value == 'M' || value == 'f' || value == 'F')
gender = value;
else
gender = DEFAULT_GENDER;
}
}
public double AnnualSalary
{
get { return annualSalary; }
set
{
if (value < MIN_SALARY)
annualSalary = MIN_SALARY;
else
if (value > MAX_SALARY)
annualSalary = MAX_SALARY;
else
annualSalary = value;
}
}
public Benefits Benefit
{
get { return benefit; }
set
{
if (value != null)
benefit = value;
else
benefit = new Benefits();
}
}
public virtual double CalculateWeeklyPay()
{
return annualSalary / 52;
}
public virtual double CalculateWeeklyPay(double modifiedSalary)
{
AnnualSalary = modifiedSalary;
return annualSalary / 52;
}
public override string ToString()
{
string output;
output = "============ Employee Information ============";
output += " Name: " + firstName + " " + lastName;
output += " Gender: " + gender;
output += " Dependents: " + dependents;
output += " Annual Salary :" + annualSalary.ToString("C2");
output += " Weekly Pay :" + CalculateWeeklyPay().ToString("C2");
output += " Employee Type:" + employeeType;
output += benefit.ToString();
return output;
}
// Constructor
public Employee(string fname, string lname, char gen, int deps, double aSalary, Benefits bene, string empType)
{
FirstName = fname;
LastName = lname;
Gender = gen;
Dependents = deps;
AnnualSalary = aSalary;
employeeType = empType;
Benefit = bene;
numEmployees += 1;
}
public Employee()
{
benefit = new Benefits();
employeeType = "Generic";
numEmployees += 1;
}
public Employee(string employeeType) : this() { }
}
class Salaried : Employee
{
const int MINIMUM_MANAGEMENT_LEVEL = 0;
const int MAXIMUM_MANAGEMENT_LEVEL = 3;
const double BONUS_PERCENT = .10;
int managementLevel;
public int ManagementLevel
{
get { return managementLevel; }
set
{
if (value < MINIMUM_MANAGEMENT_LEVEL)
managementLevel = MINIMUM_MANAGEMENT_LEVEL;
else
if (value > MAXIMUM_MANAGEMENT_LEVEL)
managementLevel = MAXIMUM_MANAGEMENT_LEVEL;
else
managementLevel = value;
}
}
public override double CalculateWeeklyPay()
{
return annualSalary / 52 * (1 + managementLevel*BONUS_PERCENT);
}
public override string ToString()
{
string output;
output = "============ Employee Information ============";
output += " Name: " + firstName + " " + lastName;
output += " Gender: " + gender;
output += " Dependents: " + dependents;
output += " Annual Salary : " + annualSalary.ToString("C2");
output += " Weekly Pay : " + CalculateWeeklyPay().ToString("C2");
output += " Employee Type: " + employeeType;
output += benefit.ToString();
output += " Management Level: " + managementLevel;
return output;
}
public Salaried()
{
employeeType = "Salaried";
}
public Salaried(string fname, string lname, char gen, int deps, double aSalary, Benefits bene,string empType, int manLevel)
: base( fname, lname, gen, deps, aSalary, bene, empType)
{
ManagementLevel = manLevel;
numEmployees += 1;
}
}
class Hourly : Employee
{
const double MIN_WAGE = 10;
const double MAX_WAGE = 75;
const double MIN_HOURS = 0;
const double MAX_HOURS = 50;
const string TEMPORARY = "temporary";
const string PART_TIME = "part time";
const string FULL_TIME = "full time";
const string INVALID_CATEGORY = "invalid category";
double wage;
double hours;
string category;
public double Wage
{
get { return wage; }
set
{
if (value < MIN_WAGE)
wage = MIN_WAGE;
else
if (value > MAX_WAGE)
wage = MAX_WAGE;
else
wage = value;
base.AnnualSalary = CalculateWeeklyPay() * 48;
}
}
public double Hours
{
get { return hours; }
set
{
if (value < MIN_HOURS)
hours = MIN_HOURS;
else
if (value > MAX_HOURS)
hours = MAX_HOURS;
else
hours = value;
base.AnnualSalary = CalculateWeeklyPay() * 48;
}
}
public string Category
{
get { return category; }
set
{
if (value == FULL_TIME || value == PART_TIME || value == TEMPORARY)
category = value;
else
category = INVALID_CATEGORY;
}
}
public override double CalculateWeeklyPay()
{
return wage * hours;
}
public Hourly()
{
employeeType = "Hourly";
}
public override string ToString()
{
string output;
output = "============ Employee Information ============";
output += " Name: " + firstName + " " + lastName;
output += " Gender: " + gender;
output += " Dependents: " + dependents;
output += " Annual Salary : " + annualSalary.ToString("C2");
output += " Weekly Pay : " + CalculateWeeklyPay().ToString("C2");
output += " Employee Type: " + employeeType;
output += benefit.ToString();
output += " Category : " + category;
output += " Hours : " + hours;
output += " Wages : " + wage;
return output;
}
public Hourly(string fname, string lname, char gen, int deps, double aSalary, Benefits bene, string empType, string cat)
: base( fname, lname, gen, deps, aSalary, bene, empType)
{
Category = cat;
numEmployees += 1;
}
}
//Program.cs
class Program
{
static void Main(string[] args)
{
ApplicationUtilities.DisplayApplicationInformation();
Employee[] emps = new Employee[3];
emps[0] = new Employee( "Generic");
emps[1] = new Hourly();
emps[2] = new Salaried();
for (int i = 0; i < emps.Length; i++)
{
ApplicationUtilities.DisplayDivider("Employee Information");
EmployeeInput.CollectEmployeeInformation(emps[i]);
if (emps[i] is Hourly)
{
EmployeeInput.CollectHourlyInformation((Hourly)emps[i]);
}
else if (emps[i] is Salaried)
{
EmployeeInput.CollectSalariedInformation((Salaried)emps[i]);
}
EmployeeOutput.DisplayEmployeeInformation(emps[i]);
ApplicationUtilities.PauseExecution();
}
EmployeeOutput.DisplayNumberObject();
ApplicationUtilities.TerminateApplication();
}
}
//Benefits.cs
class Benefits
{
const string DEFAULT_HEALTH_INSURANCE = "Blue Cross";
const double MIN_LIFE_INSURANCE = 0;
const double MAX_LIFE_INSURANCE = 1000000;
const int MIN_VACATION = 0;
const int MAX_VACATION = 45;
string healthInsuranceCompany = DEFAULT_HEALTH_INSURANCE;
double lifeInsuranceAmount = MIN_LIFE_INSURANCE;
int vacationDays = MIN_VACATION;
// Methods
public string HealthInsuranceCompany
{
get { return healthInsuranceCompany; }
set
{
if (String.IsNullOrEmpty(value))
healthInsuranceCompany = DEFAULT_HEALTH_INSURANCE;
else
healthInsuranceCompany = value;
}
}
public double LifeInsuranceAmount
{
get { return lifeInsuranceAmount; }
set
{
if (value < MIN_LIFE_INSURANCE)
lifeInsuranceAmount = MIN_LIFE_INSURANCE;
else
if (value > MAX_LIFE_INSURANCE)
lifeInsuranceAmount = MAX_LIFE_INSURANCE;
else
lifeInsuranceAmount = value;
}
}
public int VacationDays
{
get { return vacationDays; }
set
{
if (value < MIN_VACATION)
vacationDays = MIN_VACATION;
else
if (value > MAX_VACATION)
vacationDays = MAX_VACATION;
else
vacationDays = value;
}
}
public override string ToString()
{
string output;
output = " ============ Benefit Information ============";
output += " Health Insurance Company: " + healthInsuranceCompany;
output += " Life Insurance Amount: " + lifeInsuranceAmount.ToString("C2");
output += " Vacation Days: "+ vacationDays;
return output;
}
public Benefits()
{
}
public Benefits(string health, double life, int vacation)
{
HealthInsuranceCompany = health;
LifeInsuranceAmount = life;
VacationDays = vacation;
}
}
//InputUtilities.cs
public class InputUtilities
{
public static string GetInput(string inputType)
{
string strInput = String.Empty;
Console.Write("Enter the " + inputType + ": ");
strInput = Console.ReadLine();
return strInput;
}
public static string getStringInputValue(string inputType)
{
string value = String.Empty;
bool valid = false;
string inputString = String.Empty;
do
{
inputString = GetInput(inputType);
if (!String.IsNullOrEmpty(inputString))
{
value = inputString;
valid = true;
}
else
{
value = "Invalid input";
valid = false;
}
if (!valid)
Console.WriteLine("Invalid " + inputType + " try again!");
} while (!valid);
return value;
}
public static int getIntegerInputValue(string inputType)
{
bool valid = false;
int value = 0;
string inputString = String.Empty;
do
{
inputString = GetInput(inputType);
if (!(String.IsNullOrEmpty(inputString)))
{
valid = Int32.TryParse(inputString, out value);
}
if (!valid)
Console.WriteLine("Invalid " + inputType + " try again!");
} while (!valid);
return value;
}
public static double getDoubleInputValue(string inputType)
{
bool valid = false;
double value = 0;
string inputString = String.Empty;
do
{
inputString = GetInput(inputType);
if (!(String.IsNullOrEmpty(inputString)))
{
valid = Double.TryParse(inputString, out value);
}
if (!valid)
Console.WriteLine("Invalid " + inputType + " try again!");
} while (!valid);
return value;
}
public static char getCharInputValue(string inputType)
{
bool valid = false;
char value = 'u';
string inputString = String.Empty;
do
{
inputString = GetInput(inputType);
if (!(String.IsNullOrEmpty(inputString)))
{
valid = Char.TryParse(inputString, out value);
}
if (!valid)
Console.WriteLine("Invalid " + inputType + " try again!");
} while (!valid);
return value;
}
}
//ApplicationUtilities.cs
public class ApplicationUtilities
{
public static void DisplayApplicationInformation()
{
Console.WriteLine("Welcome the Basic Employee Program");
Console.WriteLine("CIS247a, Week 6 Lab");
Console.WriteLine("Name: Angela Groves");
Console.WriteLine("This program accepts user input as a string, then makes the appropriate data conversion and assigns the value to Employee objects");
Console.WriteLine();
}
public static void DisplayDivider(string outputTitle)
{
Console.WriteLine(" ********* " + outputTitle + " ********* ");
}
public static void TerminateApplication()
{
DisplayDivider("Program Termination");
Console.Write("Thank you. Press any key to terminate the program...");
Console.ReadLine();
}
public static void PauseExecution()
{
Console.Write(" Program paused, press any key to continue...");
Console.ReadLine();
Console.WriteLine();
}
}
//EmployeeInput.cs
class EmployeeInput
{
public static void CollectEmployeeInformation(Employee theEmployee)
{
theEmployee.FirstName = InputUtilities.getStringInputValue("First Name");
theEmployee.LastName = InputUtilities.getStringInputValue("Last Name");
theEmployee.Gender = InputUtilities.getCharInputValue("gender");
theEmployee.Dependents = InputUtilities.getIntegerInputValue("Number of Dependents");
if(theEmployee.EmployeeType == "Generic")
theEmployee.AnnualSalary = InputUtilities.getDoubleInputValue("Annual Salary");
theEmployee.Benefit.HealthInsuranceCompany = InputUtilities.getStringInputValue("Insurance Company");
theEmployee.Benefit.LifeInsuranceAmount = InputUtilities.getDoubleInputValue("Insurance Amount");
theEmployee.Benefit.VacationDays = InputUtilities.getIntegerInputValue("Number of Vacation Days");
}
public static
void CollectHourlyInformation(Hourly theEmployee)
{
theEmployee.Wage = InputUtilities.getDoubleInputValue("Wage");
theEmployee.Hours = InputUtilities.getDoubleInputValue("Hours");
theEmployee.Category = InputUtilities.getStringInputValue("Category");
}
public static void CollectSalariedInformation(Salaried theEmployee)
{
theEmployee.ManagementLevel = InputUtilities.getIntegerInputValue("Management Level");
theEmployee.AnnualSalary = InputUtilities.getDoubleInputValue("Annual Salary");
}
}
//EmployeeOutput.cs
class EmployeeOutput
{
public static void DisplayEmployeeInformation(Employee theEmployee)
{
Console.WriteLine(theEmployee.ToString());
}
public static void DisplayNumberObject()
{
Console.WriteLine("Number of Employees created: " + Employee.NumEmployees);
}
}
*******************
The output of theprogram should resemble the following:
Employee Type Hourly
First Name Mary
Last Name Noia
Dependents 4
Annual Salary $100,000
Weekly Pay $2,080.00
Net Pay $1,705.00
Health Insurance Blue Cross
Life Insurance $175,000
Vacation 24
Hours 40
Wage 52
Category Full Time