1)把实验对象分成处理组(待测试的药物NewDrug)、对照组(安慰剂Placebo) 2)病人(Patient)随机匹配一种药物,病人本身并不知道自己吃的是哪种药 3)医生(Doctor)也不知道病人吃得是哪种药
这个方法可以用设计模式表达出来,让我们从另一个角度来理解: public abstract class Drug { } public class NewDrug extends Drug { } public class Placebo extends Drug { } public class Patient { public void takeMedicine(Drug drug) { }; } public class Doctor { public void testDrug(Patient patient, Drug drug) { patient.takeMedicine(drug); } } public class Client { private static int PATIENT_NUM = 100; public static void main(String[] args) { Doctor doctor = new Doctor(); Patient patient; Drug drug; int newDrugNum = 0; for (int i = 0; i < PATIENT_NUM; i++) { patient = new Patient(); drug = randomDrug(); doctor.testDrug(patient, drug); if (drug instanceof NewDrug) { newDrugNum++; } } System.out.println("newDrug=" + newDrugNum); } private static Drug randomDrug() { Drug drug; double random = Math.random(); if (random < 0.5) { drug = new NewDrug(); } else { drug = new Placebo(); } return drug; } }