static void Main(string[] args) { printerWindows printer = new printerWindows(); 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 if (nomorPrinter == 3) { printer = new LaserJet(); } printer.tmpl(); printer.print(); Console.ReadKey(); }
static void Main(string[] args) { printerWindows printer = new printerWindows(); Epson epson = new Epson(); printer = epson; Canon canon = new Canon(); printer = canon; LaserJet laserjet = new LaserJet(); printer = laserjet; Console.WriteLine("Pilih Printer: "); Console.WriteLine("1. Epson"); Console.WriteLine("2. Canon"); Console.WriteLine("3. Laserjet\n"); Console.WriteLine("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(); }