?? 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 + -