I am new to object oriented development and appreciate your help in this regard. In my payroll system, I have four classes called ‘Payment’, ‘Salary’, ‘Earning’ and ‘Deduction’. preparing salary requires many types of earnings (like OT, Incentives, Spacial Allowance, payments for extra shifts, budgetary allowances, Brought forward amounts etc.) and deductions (like Insurance, Uniform, Loans,Recovery, Welfare, meals, salary advance taken etc.) So I split this in to two classes namely 'Earning' and 'Deduction'. Finally class 'Salary' is supposed to do the balancing part and class 'payment' will handle payment part (banking). Other type of payment is salary advance which is just an amount paid monthly. the relationships modeled, as follows… ‘Earning’ and ‘Deduction’ classes has a composition relationship with ‘Salary’ and ‘Salary’ is a derived class from ‘Payment’. I have implemented these relationships in my C# code as follows… My questions are
1.Whether I ve related classes in a proper way?
2.Is implementation of the relationships correct?
PAYMENTS
class payment
{
public virtual void pay()
{
}
}
SALARY
class salary:payment
{
private earning E1;
public salary()
{
E1 = new earning(this);
}
public void calEarningForSal()
{
E1.calEarning();
}
public override void pay()
{
}
}
EARNING
public class earning
{
private salary S1;
internal earning(salary sal)
{
this.S1 = sal;
}
public void calEarning()
{
}
}
MAIN METHOD
Main()
{
salary newSal = new salary();
newSal.calEarningForSal();
}