📄 pts.java
字号:
package pts;
import java.util.ArrayList;
import java.util.GregorianCalendar;
public class Pts {
public static ArrayList<Doctor> doctors;
public static ArrayList<Customer>customerBody;
public static ArrayList<Prescription>prescriptions;
public static void main(String[] args) {
Doctor d1,d2;
Customer c1,c2,c3;
Prescription p1,p2,p3,p4;
Drug dr1,dr2,dr3,dr4,dr5,dr6,dr7,dr8;
PrescriptionEntry pe1,pe2,pe3,pe4,pe5,pe6,pe7,pe8;
GregorianCalendar g1,g2,g3,g4,g5,g6,g7,g8;
//创建医生并存储于doctors之中
d1 = new Doctor("John Smith","1234567","54625","depart1","Adjunct Professor");
d2 = new Doctor("Jacquie Whiplash","7894561","25478","depart2","Full Professor");
doctors = new ArrayList<Doctor>();
doctors.add(d1);
doctors.add(d2);
//创建患者并存储于customerBody之中
c1 = new Customer("Joe Blow", "5224163","111-11-1111", "861030", "company1","2005-1");
c2 = new Customer("Fred Schnurd", "5224162","222-22-2222", "871026", "company2","2005-2");
c3 = new Customer("Mary Smith","5224165", "333-33-3333", "841230", "company3","2005-3");
customerBody = new ArrayList<Customer>();
customerBody.add(c1);
customerBody.add(c2);
customerBody.add(c3);
//创建日期
g1 = new GregorianCalendar(2002,1,2);
g2 = new GregorianCalendar(2003,6,2);
g3 = new GregorianCalendar(2003,1,3);
g4 = new GregorianCalendar(2004,3,3);
g5 = new GregorianCalendar(2004,2,4);
g6 = new GregorianCalendar(2005,1,4);
g7 = new GregorianCalendar(2005,3,5);
g8 = new GregorianCalendar(2006,1,5);
//创建药物
dr1 = new Drug("阿莫仙胶囊");
dr2 = new Drug("去痛片");
dr3 = new Drug("维生素C片");
dr4 = new Drug("六神丸");
dr5 = new Drug("氯霉素眼药水");
dr6 = new Drug("酚甘油滴耳剂");
dr7 = new Drug("庆大霉素注射液");
dr8 = new Drug("青霉素G钾注射液");
//为药物添加替代药物及副作用
dr2.addDisplace(dr8);
dr4.addDisplace(dr7);
dr2.addSideEffect("呕吐");
dr6.addSideEffect("腹泻");
dr7.addSideEffect("伤肝!!");
//创建处方并存储于prescriptions之中
p1 = new Prescription(78427,d1,c1,4,g1,g2);
p2 = new Prescription(72451,d1,c1,2,g3,g4);
p3 = new Prescription(25413,d2,c2,6,g5,g6);
p4 = new Prescription(98475,d2,c3,10,g7,g8);
prescriptions = new ArrayList<Prescription>();
prescriptions.add(p1);
prescriptions.add(p2);
prescriptions.add(p3);
prescriptions.add(p4);
//创建处方单元
pe1 = new PrescriptionEntry(dr1,p1,24,"粒",false);
pe2 = new PrescriptionEntry(dr2,p1,9,"片",true);
pe3 = new PrescriptionEntry(dr3,p1,18,"片",false);
pe4 = new PrescriptionEntry(dr4,p2,30,"粒",true);
pe5 = new PrescriptionEntry(dr5,p3,1,"支",false);
pe6 = new PrescriptionEntry(dr6,p3,1,"瓶",false);
pe7 = new PrescriptionEntry(dr7,p4,6,"支",false);
pe8 = new PrescriptionEntry(dr8,p4,6,"支",false);
/*System.out.println("====================");
System.out.println("医生信息:");
System.out.println("====================");
d1.display();
d2.display();
System.out.println();
System.out.println("====================");
System.out.println("患者信息");
System.out.println("====================");
c1.display();
c2.display();
c3.display();
System.out.println();**/
//打印处方实例
System.out.println("====================");
System.out.println("处方实例");
System.out.println("====================");
System.out.println();
p1.display();System.out.println();
p2.display();System.out.println();
p3.display();System.out.println();
p4.display();
//查询打印出用户c1的处方记录
System.out.println();
System.out.println();
System.out.println(c1.getName()+"的处方记录如下:");
allThePrescription(c1.getName());
}
//查询打印某患者的所有处方
public static void allThePrescription(String n){
for(Customer c:customerBody){
if(c.getName()==n)
c.displayPrescriptions();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -