HOURLY CLASS: using System; using System.Collections.Generic; using System.Linq;
ID: 3630571 • Letter: H
Question
HOURLY CLASS:using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//TODO implement a complete class header
namespace Payroll
{
[Serializable]
public class Hourly : Employee
{
#region "Variable Declarations"
private const double DEFAULT_HOURS = 40;
private const double DEFAULT_RATE = 10;
private const double MIN_HOURS = 0;
private const double MAX_HOURS = 50;
private const double MIN_RATE = 10;
private const double MAX_RATE = 25;
private double hours = 0;
private double rate = 0;
#endregion
#region "Constructors"
public Hourly()
{
//TODO implement
}
public Hourly(string firstName, string lastName, Employee.Type type, double hours, double rate)
: base(firstName, lastName, type)
{
//TODO implement
}
#endregion
#region "Properties"
public double Hours
{
get { return hours; }
set
{
//TODO implement--valid all hours are between minimum and maximum
}
}
public double Rate
{
get { return rate; }
set
{
//TODO implement--ensure all rates are between minimum and maximum rates
}
}
#endregion
#region "Polymorphic Methods"
public override double WeeklyPay()
{
double pay = 0.0;
if (Hours <= DEFAULT_HOURS)
pay = Rate * Hours;
else
pay = ((Hours - DEFAULT_HOURS) * 1.5 * rate) + (DEFAULT_HOURS * rate);
return pay;
}
public override string ToString()
{
return base.ToString() + ", Hours: " + hours.ToString("N2") + ", Rate: " + Rate.ToString("C2");
}
#endregion
}
}
Fill in the TODO's area and use the UML Diagram Link below and the instructions for this class/assignment.
http://www.cramster.com/answers-oct-11/computer-science/ilab-7-7-business-applicat-ilab-7-7-business-applicationsubmit-assig_1540045.aspx?rec=0
* Hourly class
// calculate and return the weekly pay
double pay = 0.0;
if( hours <= 40.0 )
pay = rate * hours;
else
pay = (hours - 40.0) * 1.5 * rate
+ 40.0 * rate;
return pay;
Explanation / Answer
This is not fully complete, however with what you've learned so far, it should be very easy to remedy. namespace Payroll { [Serializable] public class Hourly : Employee { #region "Variable Declarations" private const double DEFAULT_HOURS = 40; private const double DEFAULT_RATE = 10; private const double MIN_HOURS = 0; private const double MAX_HOURS = 50; private const double MIN_RATE = 10; private const double MAX_RATE = 25; private double hours = 0; private double rate = 0; #endregion #region "Constructors" public Hourly() : this(string.Empty, string.Empty, Type.Contract, DEFAULT_HOURS, DEFAULT_RATE) { } public Hourly(string firstName, string lastName, Employee.Type type, double hours, double rate) : base(firstName, lastName, type) { Hours = hours; Rate = rate; } #endregion #region "Properties" public double Hours { get { return hours; } set { //TODO implement--validate all hours are between minimum and maximum (hint: use an if statement) } } public double Rate { get { return rate; } set { //TODO implement--ensure all rates are between minimum and maximum rates (hint: use an if statement) } } #endregion #region "Polymorphic Methods" public override double WeeklyPay() { double pay = 0.0; if (HoursRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.