الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

ارجو المساعدة في توضيح وكتابة كود Payroll Employees

مغلق
بدأه nouralmarefa في 22 أبريل 2011 · 1 رد · 399 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

We wish to improve our payroll system to take account of the three different types of employees we actually have: exempt, non-exempt, and contract employees. Rather than use some sort of identifying code as a property, OOP makes use of inheritance to handle this need, since at runtime a type can be programmatically identified.

Also, the solution code builds upon the Person base class from the preceding example. You can either copy the Person.java file into your working directory and edit Employee.java to match.

1. Create three new classes: ExemptEmployee, NonexemptEmployee, and ContractEmployee that extend Employee.

2. In our company, exempt employees get a monthly salary, non-exempt an hourly rate that is multiplied by their hours, as do contract employees - revise the getPayInfo method to take this into account and also identify which type of employee it is (note that the payRate field will hold a monthly amount for exempt and an hourly amount for non-exempt and contractors, but these last two will need an additional field for their hours, plus methods to set and get the hours)

3. We need some way to handle the fact that contract employees do not have dependents - for now, just override listDependents to do nothing for a contract employee, and also override the addDependent method to do nothing for a ContractEmployee

o we can see here a problem with the hard-coded instantiation of the dependents array in Employee

o a better approach might be to leave it as null, and add a method to create the array, which could accept a size at that time (we won't bother to do this, since the collections classes offer a much better way that we will implement later)

4. Add constructors as you see fit

5. Have the main program create and display the information for instances of each type of employee (for now, comment out the code that uses the Employee array and just hard-code one of each type of employee).

#2

يرجى طرح سوالك باللغه العربيه مع ارفاق محاولاتك فى ذلك

لان ذلك سيعرضك لاغلاق موضوع طبعا لقوانين المنتدى

قواعد طرح المشاركات

http://www.arabteam2...showtopic=29343

Software Developer
Mahmoudkelany.com


 

هذا الموضوع مغلق.

مواضيع مشابهة