static void Main(string[] args) { Medicine a = new MedicineA("板蓝根", 11.0); Medicine b = new MedicineB("感康", 14.3); Presciption presciption = new Presciption(); presciption.addMedicine(a); presciption.addMedicine(b); Visitor charger = new Charger(); charger.setName("张三"); Visitor workerOfPharmacy = new WorkerOfPharmacy(); workerOfPharmacy.setName("李四"); presciption.accept(charger); Console.WriteLine("-------------------------------------"); presciption.accept(workerOfPharmacy); Console.ReadLine(); }
public abstract void visitor(MedicineB b);
public override void visitor(MedicineB b) { Console.WriteLine("划价员:" + name + "给药" + b.getName() + "划价:" + b.getPrice()); }
public override void visitor(MedicineB b) { Console.WriteLine("药房工作者:" + name + "拿药 :" + b.getName()); }