In corporate software, managing employee data requires a clear distinction between common identity and role-specific attributes. This project implements a Fundamental HR Module using an abstract Employee class. The base class manages shared state (the name field) and provides a concrete getName() method. Meanwhile, it enforces a getSalary() contract that must be fulfilled by concrete subclasses. The Manager class demonstrates how to implement this contract by returning a fixed compensation value while reusing the name-handling logic of the parent.
- Base State Management: Implemented a
namefield andgetName()method in the abstractEmployeeclass. - Contract Definition: Declared an abstract
getSalary()method to mandate compensation logic in subclasses. - Role Specialization: Created the
Managerclass with a dedicatedsalaryfield and getter implementation. - Constructor Chaining: Used
super(name)to pass identity data from the subclass to the abstract parent.
- Java 8+ (Abstract Classes, Inheritance, State Encapsulation)
- Employee: The abstract foundation managing identity and defining the salary contract.
- Manager: A concrete implementation representing a staff member with a fixed salary.
- HRLauncherApp: The system entry point for data verification.
Ivan
50000.0
Project Structure:
JavaBasics_Task_334/
├── src/
│ └── com/yurii/pavlenko/
│ ├── app/
│ │ └── HRLauncherApp.java
│ └── hr/
│ ├── roles/
│ │ └── Manager.java
│ └── Employee.java
├── LICENSE
├── TASK.md
├── THEORY.md
└── README.md
Code
package com.yurii.pavlenko.app;
import com.yurii.pavlenko.hr.roles.Manager;
public class HRLauncherApp {
public static void main(String[] args) {
Manager manager = new Manager("Ivan", 50000);
System.out.println(manager.getName());
System.out.println(manager.getSalary());
}
}package com.yurii.pavlenko.hr;
public abstract class Employee {
protected String name;
public Employee(String name) {
this.name = name;
}
public String getName() {
return name;
}
public abstract double getSalary();
}package com.yurii.pavlenko.hr.roles;
import com.yurii.pavlenko.hr.Employee;
public class Manager extends Employee {
private double salary;
public Manager(String name, double salary) {
super(name);
this.salary = salary;
}
@Override
public double getSalary() {
return salary;
}
}This project is licensed under the MIT License.
Copyright (c) 2026 Yurii Pavlenko
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files...
License: MIT