Let's talk about agent mode today.
What is the proxy mode? I am very busy, busy no time to talk to you, then you want to find me, I will first find my agent. Today is the scene of the boss, the Secretary, the staff.
The average employee can't see the boss. But if the employee is doing well and wants a promotion and a raise.
That's when the boss's assistant showed up. So, this time we have
Boss interface.
Assistant Class
Professional class:
An employee
—————————————————————
Boos interface.
Public interface Boos {public
void Add_money (); Pay raise public
void Add_power ()/Promotion
}
Assistant class; Implement boss interface
public class Assistan implements boos{
private Boos Boos;
Public Assistan (Boos Boos) {
this.boos = Boos;
}
public void Add_money () {
This.boos.add_money ();
}
public void Add_power () {
this.boos.add_power ();
}
}
A hard worker red. Basic appeal. Promotion pay
public class Red implements com.it.pcc.proxypatterns.boos{public
void Add_money () {
System.out.println ("Raise ");
}
public void Add_power () {
System.out.println ("promotion");
}
Workplace:
public class Staff {public
static void Main (string[] args) {red
red =new red ();
Assistan Assistan =new Assistan (red);
Assistan.add_money ();
Assistan.add_power ();
}
Basically, I want a raise. Look for the boss. The boss is not here. But the Assistant can act as the boss of these two functions.
One day is more likely to be too superficial to understand some patterns. And it's a short time to find the right scene. Today it feels like there are some flaws in this agent mode. Try to get more nutrients.