Пример #1
0
        static void Main(string[] args)
        {
            PrinterWindows printer;

            Console.WriteLine("Pilih Printer:");
            Console.WriteLine("1. Epson");
            Console.WriteLine("2. Canon");
            Console.WriteLine("3. LaserJet\n");

            Console.Write("Nomor Printer [1..3] :");
            int nomorPrinter = Convert.ToInt32(Console.ReadLine());

            if (nomorPrinter == 1)
            {
                printer = new Epson();
            }
            else if (nomorPrinter == 2)
            {
                printer = new Canon();
            }
            else
            {
                printer = new LaserJet();
            }

            printer.Show();
            printer.Print();

            Console.ReadKey();
        }
Пример #2
0
        static void Main(string[] args)
        {
            Printer printer = new Printer();

            printer.name = "Epson";
            printer.name = "Canon";
            printer.name = "LaserJet";

            Console.WriteLine("Pilih printer :\n");
            Console.WriteLine("1. Epson");
            Console.WriteLine("2. Canon");
            Console.WriteLine("3. Laser Jet");

            Console.Write("Nomor Printer [1..3] : ");
            int pil = Convert.ToInt32(Console.ReadLine());

            IPrinterWindows printerwin;

            if (pil == 1)
            {
                printerwin = new Epson();
            }
            else if (pil == 2)
            {
                printerwin = new Canon();
            }
            else
            {
                printerwin = new LaserJet();
            }

            printerwin.Show(printer);
            printerwin.Print(printer);

            Console.ReadKey();
        }