Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            PrinterWindows printer = new PrinterWindows();

            Console.WriteLine("Pilihlah Printer :\n");
            Console.WriteLine("1.Epson");
            Console.WriteLine("2.Canon");
            Console.WriteLine("3.LaserJet\n");
            Console.WriteLine("Pilih Nomor Printer = ");
            //inputting integer for branching
            int Pilihan = Convert.ToInt32(Console.ReadLine());

            //all branching for suitable condition
            if (Pilihan == 1)
            {
                printer = new Epson();
            }
            else if (Pilihan == 2)
            {
                printer = new Canon();
            }
            else if (Pilihan == 3)
            {
                printer = new Laserjet();
            }
            else
            {
                Console.WriteLine("Opsi tidak tersedia");
            }

            printer.show();
            printer.print();

            Console.ReadKey();
        }
        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("Nomer Printer [1,2,3] : ");
            int noprinter = Convert.ToInt32(Console.ReadLine());

            if (noprinter == 1)
            {
                printer = new Epson();
            }
            else if (noprinter == 2)
            {
                printer = new Canon();
            }
            else
            {
                printer = new Laserjet();
            }

            printer.show();
            printer.Print();

            Console.ReadKey();
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            //declaring the object printer that takes blueprint from PrinterWindows class
            PrinterWindows printer = new PrinterWindows();

            Console.WriteLine("Pilihlah Printer :\n");
            Console.WriteLine("1.Epson");
            Console.WriteLine("2.Canon");
            Console.WriteLine("3.LaserJet\n");
            Console.WriteLine("Pilih Nomor Printer = ");
            //inputting integer for branching
            int Pilihan = Convert.ToInt32(Console.ReadLine());

            //all branching for suitable condition
            if (Pilihan == 1)
            {
                printer = new Epson();
            }
            else if (Pilihan == 2)
            {
                printer = new Canon();
            }
            else if (Pilihan == 3)
            {
                printer = new Laserjet();
            }
            else
            {
                Console.WriteLine("Maaf, Opsi Tersebut Belum Tersedia :( Pakai Default Aja Ya :(");
            }
            //call all the method
            printer.show();
            printer.print();
            Console.ReadKey();
        }