📄 customer.java
字号:
Customer.java
import java.util.ArrayList;
import java.util.Collection;
public class Customer extends Person {
//------------
// Attributes.
//------------
private String insuranceCompany;
private String insuranceId;
private Prescription prescription;
private ArrayList<Prescription> takes;
//----------------
// Constructor(s).
//----------------
public Customer(String name, String birthday, String phone, String insuranceCompany,String insuranceId) {
// Reuse the code of the parent's constructor.
super(name, birthday,phone);
this.setInsuranceCompany(insuranceCompany);
this.setInsuranceId(insuranceId);
// Create a brand new Prescription.
this.setPrescription(prescription);
// Note that we're instantiating empty support Collection(s).
takes = new ArrayList<Prescription>();
}
// A second simpler form of constructor.
public Customer(String birthday) {
// Reuse the code of the other Student constructor.
this("家伟","19870920","07312318967","太平洋保险公司","12345678");
}
//------------------
// Accessor methods.
//------------------
public void setInsuranceCompany(String insuranceCompany) {
this.insuranceCompany = insuranceCompany;
}
public String getInsuranceCompany() {
return insuranceCompany;
}
public void setInsuranceId(String insuranceId) {
this.insuranceId = insuranceId;
}
public String getInsuranceId() {
return insuranceId;
}
public void setPrescription(Prescription p) {
prescription = p;
}
public Prescription getPrescription() {
return prescription;
}
//-----------------------------
// Miscellaneous other methods.
//-----------------------------
public void display() {
//display Customer-specific info.
System.out.println("Customer Information:");
// let's display the generic Person info.
super.display();
System.out.println("\tInsuranceCompany: " + this.getInsuranceCompany());
System.out.println("\tInsuranceId: " + this.getInsuranceId());
//this.displayCourseSchedule();
//this.printPrescription();
// Finish with a blank line.
System.out.println();
}
public String toString() {
return this.getName() + " (" + this.getBirthday() + ") [" + this.getInsuranceCompany() + "] (" + this.getInsuranceId() + " ) ";
}
public ArrayList<Prescription> getTakes() {
return takes;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -