?? pts_test.java
字號:
//測試程序
import java.util.ArrayList;
import java.util.GregorianCalendar;
public class Pts_Test {
public static ArrayList<Doctor> doctors;
public static ArrayList<Patient>patients;
public static ArrayList<Prescription>prescriptions;
public static void main(String[] args) {
Doctor d1,d2;
Patient pa1,pa2,pa3;
Prescription p1,p2,p3;
Medicine m1,m2,m3,m4,m5,m6,m7,m8;
PrescriptionEntry pe1,pe2,pe3,pe4,pe5,pe6;
GregorianCalendar g1,g2,g3,g4,g5,g6;
// 創建醫生并存儲于 doctors之中
d1 = new Doctor("John ","KaiFuQu","Mam","13456235478",45,"Adjunct Professor","surgical department ");
d2 = new Doctor("Rose ","TianXinQu","Women","15698745236",36,"Full Professor","medical department ");
doctors = new ArrayList<Doctor>();
doctors.add(d1);
doctors.add(d2);
//創建患者并存儲于Patient之中
pa1 = new Patient("Jack","TianXinQu","Man","7854963",36,"RenShouBaoXian","2032-5423");
pa2 = new Patient("Fred", "YuHuaQu","Mam","5224162",40, "ZhongHuaBaoXian", "2100-2432");
pa3 = new Patient("Smith","KaiFuQu", "Woman", "8414230", 34,"HuaKeBaoXian","2145-4533");
patients = new ArrayList<Patient>();
patients.add(pa1);
patients.add(pa2);
patients.add(pa3);
//創建日期
g1 = new GregorianCalendar(2006,7,10);
g2 = new GregorianCalendar(2006,12,10);
g3 = new GregorianCalendar(2007,1,3);
g4 = new GregorianCalendar(2007,3,3);
g5 = new GregorianCalendar(2008,2,4);
g6 = new GregorianCalendar(2008,6,4);
//創建藥物
m1 = new Medicine("Penicillin");
m2 = new Medicine("Amoxicillin");
m3 = new Medicine("Anodyne");
m4 = new Medicine("vitamineC");
m5 = new Medicine("Chloromycetin");
m6 = new Medicine("Yunnan white Ppowder");
m7 = new Medicine("Antidiarrheal Agent");
m8 = new Medicine("Coldrex");
//為藥物添加替代藥物及副作用
m1.addReplace(m8);
m3.addReplace(m6);
m4.addReplace(m7);
m3.addSideEffect("throw up");
m6.addSideEffect("skin allergy");
m8.addSideEffect("be harmful to liver");
//創建處方并存儲于prescriptions之中
p1 = new Prescription(200674,d1,pa1,4,g1,g2);
p2 = new Prescription(200685,d1,pa1,2,g3,g4);
p3 = new Prescription(200693,d2,pa2,6,g5,g6);
prescriptions = new ArrayList<Prescription>();
prescriptions.add(p1);
prescriptions.add(p2);
prescriptions.add(p3);
//創建處方單元
pe1 = new PrescriptionEntry(m1,p1,5,"bottles",false);
pe2 = new PrescriptionEntry(m2,p1,9,"pieces",true);
pe3 = new PrescriptionEntry(m3,p1,18,"pieces",false);
pe4 = new PrescriptionEntry(m4,p2,30,"pieces",true);
pe5 = new PrescriptionEntry(m5,p2,1,"bottles",false);
pe6 = new PrescriptionEntry(m6,p3,3,"bottles",false);
//打印處方實例
System.out.println(" ========= Prescription Examples ========= ");
System.out.println();
p1.display();
System.out.println();
p2.display();
System.out.println();
p3.display();
System.out.println();
//查詢打印出用戶c1的處方記錄
System.out.println();
System.out.println();
System.out.println(pa1.getName()+":\nThe record of the prescription:");
allThePrescription(pa1.getName());
}
//查詢打印某患者的所有處方
public static void allThePrescription(String n){
for(Patient pa: patients){
if(pa.getName()==n)
pa.displayPrescriptions();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -