Question: Code needs to be done in C# Design, code, and test an Employee Payroll app using the Student Database app as a template. 1.Use a
Code needs to be done in C#
Design, code, and test an Employee Payroll app using the Student Database app as a template.
1.Use a Console App (.NET Framework) workflow project type in VisualStudio
2.Database storage must use a plain text (UTF-8) file - no database software allowed
3.Use the Employee inheritance hierarchy data object classes
Heres the code:
// Fig. 12.9: PayrollSystemTest.cs
// Employee hierarchy test app.
using System;
using System.Collections.Generic;
class PayrollSystemTest
{
static void Main()
{
// create derived-class objects
var salariedEmployee = new SalariedEmployee("John", "Smith",
"111-11-1111", 800.00M);
var hourlyEmployee = new HourlyEmployee("Karen", "Price",
"222-22-2222", 16.75M, 40.0M);
var commissionEmployee = new CommissionEmployee("Sue", "Jones",
"333-33-3333", 10000.00M, .06M);
var basePlusCommissionEmployee =
new BasePlusCommissionEmployee("Bob", "Lewis",
"444-44-4444", 5000.00M, .04M, 300.00M);
Console.WriteLine("Employees processed individually: ");
Console.WriteLine($"{salariedEmployee} earned: " +
$"{salariedEmployee.Earnings():C} ");
Console.WriteLine(
$"{hourlyEmployee} earned: {hourlyEmployee.Earnings():C} ");
Console.WriteLine($"{commissionEmployee} earned: " +
$"{commissionEmployee.Earnings():C} ");
Console.WriteLine($"{basePlusCommissionEmployee} earned: " +
$"{basePlusCommissionEmployee.Earnings():C} ");
// create List
var employees = new List
hourlyEmployee, commissionEmployee, basePlusCommissionEmployee};
Console.WriteLine("Employees processed polymorphically: ");
// generically process each element in employees
foreach (var currentEmployee in employees)
{
Console.WriteLine(currentEmployee); // invokes ToString
// determine whether element is a BasePlusCommissionEmployee
if (currentEmployee is BasePlusCommissionEmployee)
{
// downcast Employee reference to
// BasePlusCommissionEmployee reference
var employee = (BasePlusCommissionEmployee)currentEmployee;
employee.BaseSalary *= 1.10M;
Console.WriteLine("new base salary with 10% increase is: " +
$"{employee.BaseSalary:C}");
}
Console.WriteLine($"earned: {currentEmployee.Earnings():C} ");
}
// get type name of each object in employees
for (int j = 0; j < employees.Count; j++)
{
Console.WriteLine(
$"Employee {j} is a {employees[j].GetType()}");
}
}
}
//End of code
4.Name your project and solution EmpDB - this will create the EmpDB namespace - all code should be placed in that namespace
5.Create at least 2 employees of each subtype for sample data in your input file - a total of 8 various employees.
6.Employee objects in the database app should be stored in a List<> at runtime - not in a static sized array.
7.Your EmpDB app should implement all 4 CRUD operations on Employee(s) in addition to processing payroll.
8.Processing payroll is simply a printout of all elements in the List along with the correct amount they should be paid based on current data.
9.The process payroll action should also print a total for the entire payroll.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
