Пример #1
0
        static void Main(string[] args)
        {
            IPrinterWindows 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)
    {
        // A new instance of the Printer class is created
        // with the variable 'p'. The methods invoked
        // will display the strings from the base class
        // methods.
        Printer p = new Printer();

        p.show();
        p.print();

        // A new instance of the LaserJet class is created
        // with the local variable 'ls'. It will implement
        // the derived class' methods and their modified
        // strings.
        Printer ls = new LaserJet();

        ls.show();
        ls.print();

        // A new instance of the Officejet class is created
        // with the variable 'of'. It will invoke the show()
        // method from the LaserJet class but implement the
        // altered string of Officejet class for the print()
        // method.
        Printer of = new Officejet();

        of.show();
        of.print();
    }
    // Driver Code
    static void Main(string[] args)
    {
        Printer p = new Printer();

        p.show();
        p.print();

        Printer ls = new LaserJet();

        ls.show();
        ls.print();

        Printer of = new Officejet();

        of.show();
        of.print();
    }
Пример #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Pilihlah Printer :\n");
            Console.WriteLine("1. Epson");
            Console.WriteLine("2. Canon");
            Console.WriteLine("3. LaserJet\n");
            Console.WriteLine("Pilih Nomor Printer = ");

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

            Console.WriteLine(" ");

            PrinterWindows tampil = null;

            if (Pilihan == 1)
            {
                printer = new Epson();
            }

            else if (Pilihan == 2)
            {
                printer = new Canon();
            }

            else if (Pilihan == 3)
            {
                printer = new LaserJet();
            }

            else
            {
                Console.WriteLine("Selain itu tidak bisa :(");
            }

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