Beispiel #1
0
        static void Main(string[] args)
        {
            ////Singleton Pattern Demo
            //Singleton instance = Singleton.getInstance();
            //instance.print();
            //Console.Read();

            //Factory Pattern Demo
            PrinterFactoryPattern fp = new PrinterFactoryPattern();

            Console.WriteLine("Please enter either Color or bw to print");
            string           input  = Console.ReadLine();
            PrinterorScanner output = fp.printInput(input);

            output.printorscan();
            Console.Read();

            //Abstract Factory Pattern Demo
            AbstractFactoryPattern afp = new AbstractFactoryPattern();

            Console.WriteLine("Please enter either Scan or Print");
            string input1 = Console.ReadLine();

            Console.WriteLine("Please enter either Color or bw");
            string input2 = Console.ReadLine();

            afp.printorscan(input1, input2);
            Console.Read();
        }
 public void printorscan(string input, string input1)
 {
     if (input == "Scan")
     {
         ScannerFactoryPattern sp = new ScannerFactoryPattern();
         PrinterorScanner      ps = sp.scanByInput(input1);
         ps.printorscan();
     }
     else
     {
         PrinterFactoryPattern ps  = new PrinterFactoryPattern();
         PrinterorScanner      pos = ps.printInput(input1);
         pos.printorscan();
     }
 }