customer.java

来自「类 &#8226 Person:PTS系统中的一个抽象类。 &#8226 C」· Java 代码 · 共 103 行

JAVA
103
字号
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 + =
减小字号Ctrl + -
显示快捷键?