+ 2
How to create a object oriented program using inheritance incorporating encapsulation and polymorphism based.
person: has no name , age and sex employee :has employee Id, workplace,years/ months in service, salary and position/title government employee : has fixed a salary in a month private agency employee: has a salary based on the rate per day ( salary= rate per day* number of days) student: has student I'd and year level high school student: college student : has additional attributes : department and course
1 Respuesta
+ 26
First identify the objects and the relations between them.
Objects (every object needs a class):
person, employee, workplace, government employee, agency employee, student, college student
Relations (unfinished, because it is not clear, if employees and students have age and sex attributes):
government employee + agency employee is-a employee
college student is-a student
All is-a employee objects has-a workplace.
is-a can be implemented by inheritance, has-a by composition.
At this point your first design draft (!) is ready.
Then go and read a lot about design patterns. After that: refactoring your design draft.