CONTRACT CLASS: using System; using System.Collections.Generic; using System.Lin
ID: 3630573 • Letter: C
Question
CONTRACT 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 contract inherits from the employee base class
public class Contract
{
#region "Variable Declarations"
private const int MIN_WEEKS = 1;
private const int MAX_WEEKS = 20;
private const double MIN_AMOUNT = 0;
private const double MAX_AMOUNT = 20000;
private int weeks = MIN_WEEKS;
private double amount = MIN_AMOUNT;
#endregion
#region "Constructors"
public Contract()
{
//TODO implement--initialize all attributes and call the base constructor
}
public Contract(string firstName, string lastName, Employee.Type type, int weeks, double amount)
{
//TODO implement--initialize all attributes and call the base constructor
}
#endregion
#region "Properties"
public int Weeks
{
get { return weeks; }
set
{
//TODO implement--ensure weeks are within MIN and MAX values
;
}
}
public double Amount
{
get { return amount; }
set
{
//TODO implement--ensure weeks are within MIN and MAX values
;
}
}
#endregion
#region "Polymorphic Methods"
//TODO overrride the employee base class WeeklyPay method
public override string ToString()
{
//TODO implement--be sure to call employee base class ToString
return "";
}
#endregion
}
}
JUST FILL IN THE TODO'S LISTED AND USE THE UML DIAGRAM LINK TO FIGURE OUT WHAT IT SHOULD LOOK LIKE AND ALSO USE THE CONTRACT INPUT INFO BELOW TOO:
http://www.cramster.com/answers-oct-11/computer-science/ilab-7-7-business-applicat-ilab-7-7-business-applicationsubmit-assig_1540045.aspx?rec=0
* Contract class
// calculate and return the weekly pay
return amount / weeks;
Explanation / Answer
namespace Payroll { [Serializable] public class Contract : Employee { #region "Variable Declarations" private const int MIN_WEEKS = 1; private const int MAX_WEEKS = 20; private const double MIN_AMOUNT = 0; private const double MAX_AMOUNT = 20000; private int weeks = MIN_WEEKS; private double amount = MIN_AMOUNT; #endregion #region "Constructors" public Contract() : this(string.Empty, string.Empty, Type.Contract, MIN_WEEKS, MIN_AMOUNT) { } public Contract(string firstName, string lastName, Employee.Type type, int weeks, double amount) : base(firstName, lastName, type) { Weeks = weeks; Amount = amount; } #endregion #region "Properties" public int Weeks { get { return weeks; } set { if (value >= MIN_WEEKS && value = MIN_AMOUNT && valueRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.