Пример #1
0
        static void Main(string[] args)
        {
            CanonPrinter canon = new CanonPrinter();

            Console.Write("Canon printer: ");
            canon.Print();

            HPPrinter hp = new HPPrinter();

            Console.Write("HP printer: ");
            hp.Print();

            Console.ReadLine();
        }
Пример #2
0
        private static IPrinter CreatePrinter()
        {
            Console.WriteLine("Choose Printer to use\n 1. HP \n 2. Canon");
            string choice = Console.ReadLine();

            if (choice == "1")
            {
                HPPrinter p = new HPPrinter();
                return(p);
            }

            else
            {
                CanonPrinter p = new CanonPrinter();
                return(p);
            }
        }
Пример #3
0
        public ContentResult Index()
        {
            String stringTemp = "";
            String PrintName  = "HP";

            if (PrintName == "HP")
            {
                IPrinter concretePrinter = new HPPrinter();
                stringTemp = concretePrinter.PrinterName() + ";" + concretePrinter.PrintPreview() + ";" + concretePrinter.Print();
            }

            else if (PrintName == "Epson")
            {
                IPrinter concretePrinter = new EpsonPrinter();
                stringTemp = concretePrinter.PrinterName() + ";" + concretePrinter.PrintPreview() + ";" + concretePrinter.Print();
            }
            String stirngNow = (new Printer()).Notation() + ";" + stringTemp;

            return(this.Content(stirngNow));
        }