예제 #1
0
        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();
        }
예제 #2
0
 public abstract void visitor(MedicineB b);
예제 #3
0
 public override void visitor(MedicineB b)
 {
     Console.WriteLine("划价员:" + name + "给药" + b.getName() + "划价:" + b.getPrice());
 }
 public override void visitor(MedicineB b)
 {
     Console.WriteLine("药房工作者:" + name + "拿药 :" + b.getName());
 }