I am learning java by following two books, I would appreciate it if anyone can help me understand couple of lines which I have seen and am unable to understand.
Lets say I have classes:
- Employee (Abstract class)
- Manager (Employee Subclass)
- Server (Employee Subclass)
- Restaurant
So pretty much "Restaurant" will have a need for "Manager" and "Server(s)". I have seen code written this way and would like to know if this valid. I have also written the same code the way I have learned. Please see that code at the bottom.
public Class Restaurant{
private Employee Manager; //I DON'T UNDERSTAND THIS
private Employee Server; //I DON'T UNDERSTAND THIS
public Restaurant(){
//I DON"T UNDERSTAND THIS
Manager = new Manager();
Server = new Server();
}
}
This is how I have learned to code:
public Class Restaurant{
private Manager _mgr;
private Server _server;
public Restaurant(){
_mgr = new Manager();
_server = new Server();
}
}