I am reading observer pattern design and could not understand the logic behind how one class calls the method of another class's method which one is not parent/child of another.
for instance i have the following Company and Employee classes.
public class Company {
String name;
public void hire() {
System.out.println("company hires employees");
}
}
class Employee {
int age;
String name;
public void gotHired() {
System.out.println("employee got hired by a company");
}
}
Is there anyway possible ways these classes could take the method of one another so that they communicate. You could add any methods that would be helpful for the explanation. Thank you