Solved

Visual Studio C# Solution

Posted on 2013-01-24
26
519 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 75

Expert Comment

by:käµfm³d 👽
ID: 38816902
What have you created so far?
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38816934
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
ID: 38816937
you could zip up your solution, but probably just best to cut and paste your employee.cs code into the question.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38816944
@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
ID: 38817149
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
ID: 38817151
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
ID: 38817153
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
ID: 38817155
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
ID: 38817157
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
ID: 38817328
What issues are you having ?
0
 

Author Comment

by:rawilken
ID: 38818992
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
ID: 38818999
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
ID: 38819001
Additional Hourly Class issue

Constructor      Constructor with 4 parameters      Rate Actual does not match Expected
0
 

Author Comment

by:rawilken
ID: 38819006
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
ID: 38819012
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
ID: 38819018
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
ID: 38819055
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
ID: 38819057
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
ID: 38819062
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
ID: 38819068
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
ID: 38819071
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
ID: 38822471
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
ID: 38822476
I did declare rate in the line above this property...
0
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 38822507
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
ID: 38841220
The answer was rate = value
0
 

Author Closing Comment

by:rawilken
ID: 38854323
No one else got it right. I solved it myself.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
WPF - Tooltips for ComboBox items 5 73
C# Offline Apllication 5 71
Help with preventing selection from a combobox 11 26
MailAddress in vb 4 15
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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)

778 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