说明:
UML
代码
package 访问者模式;
public abstract class Customer {
private String customerId;
private String name;
public abstract void serviceRequest();
public String getCustomerId() {
return customerId;
}
public void setCustomerId(String customerId) {
this.customerId = customerId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package 访问者模式;
public class EnterpriseCustomer extends Customer {
private String linkman;
private String linkTelephone;
private String registerAddress;
@Override
public void serviceRequest() {
System.out.println(this.getName()+"企业提出服务请求");
}
public String getLinkman() {
return linkman;
}
public void setLinkman(String linkman) {
this.linkman = linkman;
}
public String getLinkTelephone() {
return linkTelephone;
}
public void setLinkTelephone(String linkTelephone) {
this.linkTelephone = linkTelephone;
}
public String getRegisterAddress() {
return registerAddress;
}
public void setRegisterAddress(String registerAddress) {
this.registerAddress = registerAddress;
}
}
package 访问者模式;
public class PersonalCustomer extends Customer {
private String telephone;
private int age;
@Override
public void serviceRequest() {
System.out.println("个人客户:" +this.getName() + " 提出服务请求");
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}