예제 #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("****Hospital****\n");
            Facade.Hospital hospital = new Facade.Hospital();
            hospital.visitTherapy();

            Adapter.Reception           receptor        = new Adapter.Reception();
            Adapter.ReceptionAdapterImp receptorAdapter = new Adapter.ReceptionAdapterImp(receptor);

            Console.WriteLine("****Reception****\n");

            receptor.inform();
            receptor.register();

            Console.WriteLine("I don't speak Roumanian.");
            receptorAdapter.informInEnglish();
            receptorAdapter.registerInEnglish();

            Console.WriteLine("\n**************\n");
            Bridge.Patient patient1 = new Bridge.PatientWithPolicy(new Bridge.FreePolicy());
            patient1.create();
            Bridge.Patient patient2 = new Bridge.PatientWithoutPolicy(new Bridge.PurchasedPolicy());
            patient2.create();

            Console.WriteLine("\n**************\n");
            Decorator.Doctor doctor = new Decorator.Treatment(new Decorator.Surgery(new Decorator.DoctorImp()));
            Console.WriteLine(doctor.investigate());

            Console.WriteLine("\n**************\n");

            Flyweight.DiseaseFactory factory = new Flyweight.DiseaseFactory();

            Flyweight.Target disease1 = new Flyweight.Target();
            disease1.ID          = Guid.NewGuid();
            disease1.DiseaseData = factory.getTreatment("Gripa");

            Flyweight.Target disease2 = new Flyweight.Target();
            disease2.ID          = Guid.NewGuid();
            disease2.DiseaseData = factory.getTreatment("Gripa");

            bool result = disease1.DiseaseData == disease2.DiseaseData;     // result = true

            Console.WriteLine("Sunt identice obiectele: " + result);
            string state = disease1.DiseaseData.state;

            Console.WriteLine("Instante Desease: " + Flyweight.Treatment.NumberOfInstances);

            Console.ReadKey();
        }
예제 #2
0
파일: Disease.cs 프로젝트: dumitritag/lab2
 public abstract void write(Target target);