Пример #1
0
        static void Main(string[] args)
        {
atas:

            PrinterWindows printer;

            Console.WriteLine("\nPilih Printer :");
            Console.WriteLine("1. Epson");
            Console.WriteLine("2. Canon");
            Console.WriteLine("3. LaserJet\n");
            Console.Write("Nomor Printer [1,2,3] : ");

            int pilihPrinter = Convert.ToInt32(Console.ReadLine());

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

            printer.show();
            printer.print();
            Console.ReadKey();

            goto atas;
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Pilih Printer: ");
            Console.WriteLine("1. Epson");
            Console.WriteLine("2. Canon");
            Console.WriteLine("3. Laser Jet\n");

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

            IPrinterWindows printer = new PrinterWindows();

            if (nomorPrinter == 1)
            {
                printer = new Epson();
            }
            else if (nomorPrinter == 2)
            {
                printer = new Canon();
            }
            else if (nomorPrinter == 3)
            {
                printer = new LaserJet();
            }
            else
            {
                Console.WriteLine("EROR");
            }

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

            Console.ReadKey();
        }