1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
@AllArgsConstructor
public static abstract class Person {
protected String name;
protected Mediator mediator;
}
public static class HouseOwner extends Person {
public HouseOwner(String name, Mediator mediator) {
super(name, mediator);
}
public void contact(String message) {
mediator.contact(message, this);
}
public void getMessage(String message) {
System.out.println("房主" + name + "获取到的信息是:" + message);
}
}
public static class Tenant extends Person {
public Tenant(String name, Mediator mediator) {
super(name, mediator);
}
public void contact(String message) {
mediator.contact(message, this);
}
public void getMessage(String message) {
System.out.println("租房者" + name + "获取到的信息是:" + message);
}
}
|