⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 consumer.java

📁 处方跟踪系统的开发
💻 JAVA
字号:
import java.util.*;
import java.lang.*;
public class Consumer
{
	private int cId;
	private String name;
	private String phoneNo;
	private String birthday;
	private String company;
	private String insuranceNo;
	private ArrayList<Prescription> prescriptionsOffered; 
	//有参构造器
	public Consumer(int cId,String name,String phoneNo,String birthday,String company,String insuranceNo)
	{
		this.setCId(cId);
		this.setName(name);
		this.setPhoneNo(phoneNo);
		this.setBirthday(birthday);
		this.setCompany(company);
		this.setInsuranceNo(insuranceNo);
        prescriptionsOffered=new ArrayList<Prescription>();	 		
	}
	//无参构造器
	public Consumer()
	{
		this.setCId(0);
		this.setName("?/");
		this.setPhoneNo("??");
		this.setBirthday("???");
		this.setCompany("????");
		this.setInsuranceNo("?????");	
        prescriptionsOffered=new ArrayList<Prescription>();	
	}
    //cId的get和set方法
	public int getCId()
	{
	   return this.cId;
	}
	public void setCId(int cId)
	{
	  this.cId=cId;
	}
	//name的get和set方法
	public String getName()
	{
	   return this.name;
	}
	public void setName(String name)
	{
	  this.name=name;
	}
	//phoneNo的get和set方法
	public String getPhoneNo()
	{
	   return this.phoneNo;
	}
	public void setPhoneNo(String phoneNo)
	{
	  this.phoneNo=phoneNo;
	}
	//birthday的get和set方法
	public String getBirthday()
	{
	   return this.birthday;
	}
	public void setBirthday(String birthday)
	{
	  this.birthday=birthday;
	}
	//company的get和set方法
	public String getCompany()
	{
	   return this.company;
	}
	public void setCompany(String company)
	{
	  this.company=company;
	}
	//insuranceNo的get和set方法
	public String getInsuranceNo()
	{
	   return this.insuranceNo;
	}
	public void setInsuranceNo(String insuranceNo)
	{
	  this.insuranceNo=insuranceNo;
	}
        //历史记录
	public ArrayList<Prescription> getPrescriptionsOffered()
	{
        return prescriptionsOffered;
    }
         //添加历史记录
	public void addPrescriptionsOffered(Prescription p)
	{ 
		if (!prescriptionsOffered.contains(p))
		{	      
	          prescriptionsOffered.add(p);
		}		
	}
     //定义toString()方法
    public String toString()
	{
		return this.getName()+"(\n"+this.getCId()+"\n"+this.getPhoneNo()+"\n"+this.getBirthday()+"\n"+this.getCompany()+"\n"+this.getInsuranceNo()+")";
	}
	//定义一个界面显示方法
/*	public String displayInfo()
	{
		 StringBuilder str;
		 str.append(this.toString());
	     for (Prescription p : prescriptionsOffered)
	     {
            str.append(p.toString());          
	     }
		 return str.toString();
		
	} */
       //定义display()方法
	public void display()
	{
	  System.out.println("The person's id is : "+this.getCId());
	  System.out.println("The person's name is: "+this.getName());
	  System.out.println("The person's phoneNo is: "+this.getPhoneNo());
	  System.out.println("The person's birthday is: "+this.getBirthday());
	  System.out.println("The person's company is: "+this.getCompany());
	  System.out.println("The person's insuranceNo is: "+this.getInsuranceNo());	         	
	  for (Prescription p : prescriptionsOffered)
	  {
            p.display();
            System.out.println();
	  }
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -