OOP Pay Management System

This project demonstrates the use of object-oriented programming principles, including interfaces, abstract classes, and polymorphism, to calculate payments for various types of objects (invoices and programmers) in a polymorphic manner.

Key Concepts:

Abstract Classes:

  • The Programmer class is abstract and provides common attributes (name, social security number, etc.) and an abstract method getPaymentAmount() that each subclass overrides.

Interfaces:

  • The Payme interface defines a contract that all implementing classes must fulfill by providing their own implementation of getPaymentAmount().

Inheritance:

  • Subclasses (SalariedProgrammer, HourlyProgrammer, CommissionProgrammer, and BasePlusCommissionProgrammer) extend the abstract Programmer class, inheriting its fields and methods.

Polymorphism:

  • Objects of various types (Invoice, Programmer subclasses) are processed using the common Payme interface reference.

Encapsulation:

  • Each class uses private fields and provides public getters and setters to manage them, ensuring data integrity.

Dynamic Behavior:

In the PaymeInterfaceTest class:

  • An array of Payme references stores objects of both unrelated (Invoice) and related (Programmer subclasses) types.

  • During runtime, the program:

    1. Iterates over the array.

    2. Dynamically calls the appropriate getPaymentAmount() implementation for each object.

    3. Processes a special case for BasePlusCommissionProgrammer by increasing its base salary by 5% before calculating the payment.

Objective:

  1. Create a hierarchy of programmer classes using inheritance and polymorphism.

  2. Use the Payme interface to standardize the calculation of payment amounts for all classes implementing the interface.

  3. Process different objects polymorphically using a common interface and dynamically determine their payment amounts.

  4. Demonstrate polymorphic behavior by processing both unrelated classes (Invoice) and related subclasses (Programmer hierarchy).