Solved

Visual Studio C# Solution

Posted on 2013-01-24
26
512 Views
Last Modified: 2013-02-05
I hate to do this, but I need help. I bit off more than I can chew. I am taking a C# II class. I did not take the C# I class first. Based on another class the prof thought I would be alright. Well I am not.
I have an assignment to create a project. I am attaching the specifications in a PDF.
I am also attaching what I have been able to accomplish so far. At this point I am sort of lost. I would appreciate it if someone could at least walk me through completing this project.
There are two projects in the solution. One, OopGrader is the self grading application that, when run, tells you what is correct and what is not. To run the grader, there is a line in the AppConfig file of the project that needs to be altered to report the directory in which the solution is saved. This was provided by the prof. The second is call Project1 and this is where I have created my code.

I hope someone out there is willing to take on a novice and guide him through this, what probably is easy to some, assignment.

Let me make a bit of a change to this...
I cannot upload the project. The files contained within it are not allowed extensions (suo, dll). So I need someone to help me get them the solution as well as taking on helping me
Specifications.pdf
0
Comment
Question by:rawilken
  • 20
  • 3
  • 3
26 Comments
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
What have you created so far?
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
Also, you might want to look at the C# videos that EE has:  http://www.experts-exchange.com/tutorials/cSharp.jsp
0
 
LVL 29

Expert Comment

by:Paul Jackson
Comment Utility
you could zip up your solution, but probably just best to cut and paste your employee.cs code into the question.
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
@jacko72

EE inspects zip files as well. It won't permit offending files even if they are zipped. (Found out the hard way!)
0
 

Author Comment

by:rawilken
Comment Utility
Employee Class

namespace Project1
{
    public abstract class Employee
    {
        public const string Programmer = "Rodd Wilken";

        public int EmpID{ get; set; }

        public string FirstName { get; set; }
       
        public string LastName { get; set; }

        public List<PayCheck> PayChecks { get; set; }

        public decimal PayAmount { get; set; }

        public abstract decimal GetPayAmount();

        public PayCheck PayEmployee(DateTime payDate)
        {
            PayCheck payCheck = new PayCheck(this, payDate);
            PayChecks.Add(payCheck);
            return payCheck;
        }

        public decimal YtdPay()
        {
            decimal value = 0;
            for (int index = 0; index < PayChecks.Count; index++)
            {
                value = value + PayAmount;
            }
            return value;
        }

        public Employee(int empId, string firstName, string lastName)
        {
            EmpID = empId;
            FirstName = firstName;
            LastName = lastName;
            PayChecks = new List<PayCheck>();
        }

        public Employee() : this(0, String.Empty, String.Empty)
        {
         
        }
    }
}
0
 

Author Comment

by:rawilken
Comment Utility
Hourly Class

namespace Project1
{
    public class Hourly : Employee
    {
        public decimal GetRegularPay()
        {
            decimal regPay;

            if (Hours >= 40)
            {
                regPay = 40*Rate;
            }
            else
            {
                regPay = Hours*Rate;
            }
            return regPay;
        }

        public decimal GetOtPay()
        {
            decimal otPay = 0;
            if (Hours > 40)
            {
                otPay = (Hours - 40)*(Rate + (Rate/2));
            }
            return otPay;
        }

        public const decimal MinimumWage = (decimal) 7.75;

        public decimal Hours { get; set; }

        private decimal rate;

        public decimal Rate
        {
            get
            {
                return rate;
            }
            set
            {
                if (MinimumWage > Rate)
                    rate = (decimal)7.75;
            }
        }
   
        public override decimal GetPayAmount()
        {
            if (Hours > 40)
            {
                PayAmount = ((Hours - 40)*(Rate+(Rate/2))) + (40*Rate);
            }
            else
            {
                PayAmount = (Hours*Rate);
            }
            return PayAmount;
        }

        public Hourly(int empID, string firstName, string lastName, decimal rate)
            :base(empID,firstName,lastName)
        {
            Rate = rate;
        }

        public Hourly() : this(0, String.Empty, String.Empty, 0)
        {
        }
    }
}
0
 

Author Comment

by:rawilken
Comment Utility
Paycheck Class

namespace Project1
{
    public class PayCheck
    {
        public Employee Employee { get; set; }

        public DateTime PayDate { get; set; }

        public decimal Amount { get; set; }

        public PayCheck(Employee emp, DateTime payDate)
        {
            Employee = emp;
            PayDate = payDate;
            Amount = 0; // emp.GetPayAmount();
        }
    }
}
0
 

Author Comment

by:rawilken
Comment Utility
Salary Class

namespace Project1
{
    public class Salary : Employee
    {
        public decimal AnnualSalary { get; set; }

        public override decimal GetPayAmount()
        {
            return AnnualSalary/52;
        }

        public Salary(int empId, string firstName, string lastName, decimal annualSalary)
            : base(empId, firstName, lastName)
        {
            AnnualSalary = annualSalary;
        }

        public Salary() : this(0, String.Empty, string.Empty, 0)
        {
        }
    }
}
0
 

Author Comment

by:rawilken
Comment Utility
Sales Class

namespace Project1
{
    public class Sales : Employee
    {
        public decimal SalesThisPeriod { get; set; }

        public decimal CommissionRate { get; set; }
       
        public override decimal GetPayAmount()
        {
            return CommissionRate*SalesThisPeriod;
        }

        public Sales(int empId, string firstName, string lastName, decimal commissionRate, decimal salesThisPeriod)
            : base(empId, firstName, lastName)
        {
            CommissionRate = commissionRate;
            SalesThisPeriod = salesThisPeriod;
        }

        public Sales() : this(0, String.Empty, String.Empty, 0, 0)
        {
        }
    }
}
0
 
LVL 29

Expert Comment

by:Paul Jackson
Comment Utility
What issues are you having ?
0
 

Author Comment

by:rawilken
Comment Utility
Issues with Employee Class

Property      PayChecks      Salary PayCheck Actual does not match Expected

Method      PayEmployee      Hourly Pay for 40 hours @ 0 rate  Actual does not match Expected

Method      YtdPay      Hourly YTD Pay Actual does not match Expected
0
 

Author Comment

by:rawilken
Comment Utility
Issues with Hourly Class

Property      Rate      Pay Rate Actual does not match Expected

Property      PayChecks      Hourly PayCheck Actual does not match Expected

Method      PayEmployee      Hourly Pay for 40 hours @ 0 rate  Actual does not match
Expected

Method      GetPayAmount      Not found

Method      GetRegularPay      40.5 hours at a rate of 12.75  Actual does not match Expected

Method      GetOTPay      Property not found

Method      YtdPay      Hourly YTD Pay Actual does not match Expected
0
 

Author Comment

by:rawilken
Comment Utility
Additional Hourly Class issue

Constructor      Constructor with 4 parameters      Rate Actual does not match Expected
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:rawilken
Comment Utility
Salary Class ISsues

Property      PayChecks      Salary PayCheck Actual does not match Expected
      
Method      YtdPay      Salary YTD Pay Actual does not match Expected
0
 

Author Comment

by:rawilken
Comment Utility
Sales Class Issues

Property      PayChecks      Sales PayCheck Actual does not match Expected

Method      PayEmployee      Sales Pay Check Actual does not match Expected      

Method      YtdPay      Sales YTD Pay Actual does not match Expected
0
 

Author Comment

by:rawilken
Comment Utility
Paycheck Class ISsues

Property      Amount      Property is not Read Only

Functional      Hourly Paychecks      Hourly PayCheck Actual does not match Expected

Functional      Sales Paychecks      Sales PayCheck Actual does not match Expected

Functional      Salary Paychecks      Salary PayCheck Actual does not match Expected

Functional      Employee Paychecks      Salary PayCheck Actual does not match Expected
0
 

Author Comment

by:rawilken
Comment Utility
Employee Class Requirements

Employee

Create an abstract Employee class that has the following:

 
• public constant Programmer as a string where the value is your name
•public EmpID property as an integer
• public FirstName property as a string
• public LastName property as a string
• public PayChecks property as a List of PayCheck objects
• public PayAmount property as a decimal
• public GetPayAmount( ) as an abstract method that returns a decimal
• public PayEmployee(DateTime PayDate) method that creates a PayCheck object for an employee, adds the object to the PayChecks collection, and returns the PayCheck object
• public YtdPay() method that returns a decimal for the sum of the pay checks in the PayChecks collection
• public constructor method that has these parameters: int EmpID, string FirstName, string LastName. The constructor populates the corresponding properties.
• public default contructor method that initializes the properties about with a zero (0) and two empty strings
0
 

Author Comment

by:rawilken
Comment Utility
Hourly Class requirements

Hourly

Create a concrete Hourly class that inherits from the Employee class and has the following:

 
• NEW*** public GetRegularPay method as a decimal.
• NEW*** public GetOTPay method as a decimal.
• public constant decimal named MinimumWage with a value of $7.75
• public Hours property as a decimal
• public Rate property as a decimal. If the Rate property is set to less than the Minimum Wage, then set it to the Minimum Wage.
• Instantiate the GetPayAmount( ) method that overrides the Employee's method to calcuate the pay amount for a pay period. Hours up to 40 hours are calculated at the employee's Rate. Hours above 40 hours are calcualated as the employee's Rate for the first 40 hours and 1.5 times the employee's Rate for all hours over 40 hours.
• public constructor method that has these parameters: int EmpID, string FirstName, string LastName, decimal Rate. The constructor populates the corresponding properties, using the Employee's constructor for the first three properties.
• public default contructor method that initializes the properties about with a zero (0) for the EmployeeID, two empty strings for the first and last names, and a 0 for the Rate.
0
 

Author Comment

by:rawilken
Comment Utility
Salary Class requirements

Salary

Create a concrete Salary class that inherits from the Employee class and has the following:

 
• public AnnualSalary property as a decimal
• Instantiate the GetPayAmount( ) method that overrides the Employee's method to calcuate the pay amount for a pay period. The pay amount is calculated as the annual salary divided by 52 (weeks in a year).
• public constructor method that has these parameters: int EmpID, string FirstName, string LastName, decimal AnnualSalary. The constructor populates the corresponding properties, using the Employee's constructor for the first three properties.
• public default contructor method that initializes the properties about with a zero (0) for the EmployeeID, two empty strings for the first and last names, and a 0 for the AnnualSalary.
0
 

Author Comment

by:rawilken
Comment Utility
Sales Class requirements

Sales

Create a concrete Sales class that inherits from the Employee class and has the following:

 
• public SalesThisPeriod property as a decimal
• public CommissionRate property as a decimal
• Instantiate the GetPayAmount( ) method that overrides the Employee's method to calcuate the pay amount for a pay period. The pay amount is calculate as the commission rate times the sales this period.
• public constructor method that has these parameters: int EmpID, string FirstName, string LastName, decimal CommissionRate, decimal SalesThisPeriod. The constructor populates the corresponding properties, using the Employee's constructor for the first three properties.
• public default contructor method that initializes the properties about with a zero (0) for the EmployeeID, two empty strings for the first and last names, and zero for the last two (commission rate and sales this period).
0
 

Author Comment

by:rawilken
Comment Utility
PayCheck class requirements

PayCheck

Create a concrete PayCheck class that does not inherit from anything. It has these characteristics:

 
• public Employee property as an Employee object
• public PayDate property as a DateTime object
• public Amount read only property as a decimal. Store the value as a private instance variable.
• public constructor method that has these parameters: Employee and DateTime for PayDate. Set the Employee and PayDate properties. Set the private instance variable for Amount by calling the Employee's GetPayAmount( ) method.
• There is no default constructor method for this class.
0
 

Author Comment

by:rawilken
Comment Utility
I think I have everything worked out except for the Rate property in the Hourly Class...

This is what I have...

public decimal Rate
        {
            get { return rate; }
           
            set
            {
                rate = Rate;
                if (rate < MinimumWage)
                {
                    rate = MinimumWage;
                }
                else
                {
                    rate = Rate;
                }
            }
        }

What I need to do is check the value of Rate to see if it is below the MinimumWage. If it is, assign the MinimumWage to it. If not use it as is.
0
 

Author Comment

by:rawilken
Comment Utility
I did declare rate in the line above this property...
0
 
LVL 29

Expert Comment

by:Paul Jackson
Comment Utility
try removing the          rate = Rate;  in the set before the if so its like:

public decimal Rate
        {
            get { return rate; }
           
            set
            {
                if (rate < MinimumWage)
                {
                    rate = MinimumWage;
                }
                else
                {
                    rate = Rate;
                }
            }
        }
0
 

Accepted Solution

by:
rawilken earned 0 total points
Comment Utility
The answer was rate = value
0
 

Author Closing Comment

by:rawilken
Comment Utility
No one else got it right. I solved it myself.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now