📄 prescription.java
字号:
//处方类
import java.util.*;
public class Prescription {
//------------
// Attributes.
//------------
private int prescriptionNo;//处方的第ID号
private GregorianCalendar startTime;//处方日期
private GregorianCalendar endTime;//处方终止日期
private int numberTime;//处方使用次数
private Doctor PrescriptionMaker;
private Patient PrescriptionOwner;
private boolean use;//处方是否可用
private ArrayList<PrescriptionEntry>PrescriptionEnties;
//----------------
// Constructor(s).
//----------------
public Prescription(int pn,Doctor d,Patient pa,int nt,GregorianCalendar st,GregorianCalendar et){
setPrescriptionNo(pn);
setStartTime(st);
setEndTime(et);
setPrescriptionMaker(d);
setPrescriptionOwner(pa);
setNumberTime(nt);
PrescriptionEnties = new ArrayList<PrescriptionEntry>();
pa.addPrescription(this);
}
public void setNumberTime(int nt) {
numberTime = nt;
}
public int getNumberTime(){
return numberTime;
}
public void setStartTime(GregorianCalendar st) {
startTime = st;
}
public GregorianCalendar getStartTime(){
return startTime;
}
public void setEndTime(GregorianCalendar et) {
endTime = et;
}
public GregorianCalendar getEndTime(){
return endTime;
}
public void setPrescriptionNo(int pn) {
prescriptionNo = pn;
}
public int getPrescriptionNo(){
return prescriptionNo;
}
public void setPrescriptionMaker(Doctor d) {
PrescriptionMaker = d;
}
public Doctor getPrescriptionMaker(){
return PrescriptionMaker;
}
public void setPrescriptionOwner(Patient pa) {
PrescriptionOwner = pa;
}
public Patient getPrescriptionOwner(){
return PrescriptionOwner;
}
public void setUse(){
GregorianCalendar et2 = new GregorianCalendar();
if(getNumberTime()>0 && et2.equals(getEndTime()))
use = true;
}
public boolean getUse(){
return use;
}
//添加处方单元
public void addPrescriptionEntry(PrescriptionEntry p){
PrescriptionEnties.add(p);
p.setPrescription(this);
}
public String toString(){
return "prescriptionNo:" + getPrescriptionNo();
}
//打印出处方信息
public void display(){
System.out.println("prescriptionNo:"+getPrescriptionNo());
System.out.print("Patient");
getPrescriptionOwner().display();
System.out.print("Doctor");
getPrescriptionMaker().display();
System.out.println("The description of taking medicine && remarks: ");
for(PrescriptionEntry p :PrescriptionEnties ){
System.out.print(p.getMedicine().getMedicineName()+": "+p.getQuantities()+p.getUnit()+",");
if(p.isCanReplace()){
System.out.print("Could be replaced by "+p.getMedicine().displayReplace()+"....");
}
else
System.out.print("Could not be replaced"+",");
if(p.getMedicine().hasSideEffectOrNot()){
System.out.print("has SideEffect"+p.getMedicine().displaySideEffect()+".");
}
else System.out.print("has not SideEffect"+".");
System.out.println();
}
System.out.println("The times of using the prescription: "+ getNumberTime());
System.out.println("The starttime of prescription: "+ startTime.getTime());
System.out.println("The endtime of prescription: "+ endTime.getTime());
}
//抓药
public void getMedicine(){
setUse();
if(getUse()){
System.out.print("could write prescription");
numberTime--;
}
else
System.out.print("this prescription is useless,so could not wrtie the prescription!!!!!!");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -