diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/core/modifiers/Employee.java b/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/core/modifiers/Employee.java index e43b6634ed..6ec68d6ebb 100644 --- a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/core/modifiers/Employee.java +++ b/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/core/modifiers/Employee.java @@ -3,12 +3,12 @@ package com.baeldung.core.modifiers; public class Employee { private String privateId; - public String name; + private String name; private boolean manager; public Employee(String id, String name) { - changeId(id); - this.name = name; + setPrivateId(id); + setName(name); } private Employee(String id, String name, boolean managerAttribute) { @@ -17,7 +17,7 @@ public class Employee { this.privateId = id + "_ID-MANAGER"; } - public void changeId(String customId) { + public void setPrivateId(String customId) { if (customId.endsWith("_ID")) { this.privateId = customId; } else { @@ -25,7 +25,7 @@ public class Employee { } } - public String getId() { + public String getPrivateId() { return privateId; } @@ -43,6 +43,15 @@ public class Employee { this.manager = manager; } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + public static Employee buildManager(String id, String name) { return new Employee(id, name, true); } diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/core/modifiers/ExampleClass.java b/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/core/modifiers/ExampleClass.java index db58b4f00b..41f0b7a690 100644 --- a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/core/modifiers/ExampleClass.java +++ b/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/core/modifiers/ExampleClass.java @@ -4,7 +4,7 @@ public class ExampleClass { public static void main(String[] args) { Employee employee = new Employee("Bob","ABC123"); - employee.changeId("BCD234"); - System.out.println(employee.getId()); + employee.setPrivateId("BCD234"); + System.out.println(employee.getPrivateId()); } }