EMPLOYEE CLASS: using System; using System.Collections.Generic; using System.Lin
ID: 3630572 • Letter: E
Question
EMPLOYEE CLASS:using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//TODO implement a complete class header
namespace Payroll
{
[Serializable]
//TODO modify so that employee class implements the IPayable interface
public abstract class Employee
{
#region "Variable Declarations"
//create an enumeration that keeps track of the type
public enum Type
{
Hourly = 1,
Salary = 2,
Contract = 3,
None = 4
};
private string firstName = String.Empty;
private string lastName = String.Empty;
private Type employeeType;
#endregion
#region "Pure Virtual Functions"
public abstract double WeeklyPay();
#endregion
#region "Constructors"
protected Employee()
{
//TODO implement default constructor and intialize variables
}
protected Employee(string firstName, string lastName, Employee.Type type)
{
//TODO initialize variables
}
#endregion
#region "Properties"
public string FirstName
{
//TODO implement
get { return ""; }
set { ; }
}
public string LastName
{
//TODO implement
get { return "" ; }
set { ; }
}
public string FullName
{
//TODO implement--read only property
get { return ""; }
}
public string EmployeeType
{
get
{
string type;
switch (employeeType)
{
case Type.Hourly:
type = "Hourly Employee";
break;
case Type.Salary:
type = "Salary Employee";
break;
case Type.Contract:
type = "Contract Employee";
break;
default:
type = "None";
break;
}
return type;
}
}
#endregion
#region "IPayable Interface Implemenation"
public string GetName()
{
//TODO implement
return "";
}
public double GetAmount()
{
//TODO implement
return (double) 0;
}
#endregion
#region "Virtual Methods"
public override string ToString()
{
//TODO implement
return "";
}
#endregion
}
}
FILL IN THE TODO'S AREA'S AND USE THE INFORMATION AND UML DIAGRAM LINK BELOW:
http://www.cramster.com/answers-oct-11/computer-science/ilab-7-7-business-applicat-ilab-7-7-business-applicationsubmit-assig_1540045.aspx?rec=0
* Employee class – code for ToString( ) method
// return the name of the payee
return firstName + " " + lastName;
* Employee class – code for GetAmount( ) method
// return the amount to pay the employee
return WeeklyPay( );
* Notice that the abstract Employee class implements from the IPayable interface. You need to implement the inheritance relationship.
Explanation / Answer
This is not a complete answer, but you should be able to easily finish this with all that you've learned so far. namespace Payroll { [Serializable] public abstract class Employee : IPayable { #region "Variable Declarations" //create an enumeration that keeps track of the type public enum Type { Hourly = 1, Salary = 2, Contract = 3, None = 4 }; private string firstName = String.Empty; private string lastName = String.Empty; private Type employeeType; #endregion #region "Pure Virtual Functions" public abstract double WeeklyPay(); #endregion #region "Constructors" protected Employee() : this(string.Empty, string.Empty, Type.Contract) { } protected Employee(string firstName, string lastName, Employee.Type type) { //TODO initialize variables } #endregion #region "Properties" public string FirstName { //TODO implement –use get;set here } public string LastName { //TODO implement –use get;set here } public string FullName { get { return string.Concat(firstName, " ", lastName); } } public string EmployeeType { get { string type; switch (employeeType) { case Type.Hourly: type = "Hourly Employee"; break; case Type.Salary: type = "Salary Employee"; break; case Type.Contract: type = "Contract Employee"; break; default: type = "None"; break; } return type; } } #endregion #region "IPayable Interface Implemenation" public string GetName() { return FullName; } public double GetAmount() { return WeeklyPay(); } #endregion #region "Virtual Methods" public override string ToString() { return FullName; } #endregion } }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.