Clicky

Hi,
I have attached a emp paycheck uml diagram as doc file. An employee --> paycheck cardinality is 1..*, and it is bidirectional. Paycheck is an aggregate in payroll class(one payroll class has multiple paychecks) and it is bidirectional. In payroll class we have a Date field. My question is I need to write a method which takes emp, date, date(three parameters) as parameters and returns double. I need to write a code to return the gross amount an emp received between two dates. These two dates are part of payroll class.
uml.doc (14 KB)
employee payroll uml (application/msword)

asked 09/27/2010 02:32

prsubject's gravatar image

prsubject ♦♦


4 Answers:
What is the issue? If I understand what you're doing, you need something like attached pseudo-code
1:
2:
3:
4:
5:
6:
7:
Payroll.getGrossPayFor( Employee anEmployee) {
   for each paycheck {
      total += nextPaycheck.getGrossAmount();
   }
   return total;
}
link
marklorenz's gravatar image

marklorenz

<pre id="codeSnippet1094273" class="notpretty">Payroll.getGrossPayFor( Employee anEmployee, Date dt1, Date dt2)//between date1 and Date2
{   The Date is in Payroll class.

}
</pre>
link
prsubject's gravatar image

prsubject

                                                                     0..1            *                      *                         1
Totally there are three class Employee<-------------->paycheck<-------------------<>Payroll.
Paycheck is an aggregate of payroll and both the relations are bidirectional
link
prsubject's gravatar image

prsubject

Being bidirectional doesn't affect summing the gross amounts of each paycheck for a particular employee. Just get the paychecks for the payroll, and ask each one if it is for an employee and if so add the gross pay from that paycheck.
link
marklorenz's gravatar image

marklorenz

Your answer
[hide preview]

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×5

Asked: 09/27/2010 02:32

Seen: 328 times

Last updated: 09/27/2010 09:50