private static void CreateEpsonPrinter(PrinterManager m) { string name = Console.ReadLine(); string model = Console.ReadLine(); m.Add(new EpsonPrinter(name, model)); }
private static void CreatePrinter() { Printer printer = new Printer(); try { Console.WriteLine("Enter printer name"); printer.Name = Console.ReadLine(); Console.WriteLine("Enter printer model"); printer.Model = Console.ReadLine(); if (PrinterManager.Add(printer)) { Console.WriteLine("Printer added."); } else { Console.WriteLine("Printer already exists."); } } catch (ArgumentNullException) { Console.WriteLine("Name or Model can't be empty!"); } }
private static void CreatePrinter() { string name = "RandomPrinter"; Printer printer; Console.Clear(); Console.WriteLine("Choose a model:\n1.Canon\n2.Epson\n3.Other"); var key = Console.ReadKey(); Console.Clear(); try { if (key.Key == ConsoleKey.D3) { Console.WriteLine("Enter printer name"); name = Console.ReadLine(); } Console.WriteLine("Enter printer model"); string model = Console.ReadLine(); switch (key.Key) { case ConsoleKey.D1: { printer = new CanonPrinter(model); break; } case ConsoleKey.D2: { printer = new EpsonPrinter(model); break; } default: { printer = new RandomPrinter(name, model); break; } } try { printerManager.Add(printer); Console.WriteLine("Printer added."); } catch (InvalidOperationException) { Console.WriteLine("Printer already exists."); } } catch (ArgumentNullException) { Console.WriteLine("Name or Model can't be empty!"); } }
static void Main(string[] args) { Console.WriteLine("Select your choice:"); Console.WriteLine("0:Add new Epson printer"); Console.WriteLine("1:Add new Canon printer"); Console.WriteLine("2:Print on Canon"); Console.WriteLine("3:Print on Epson"); DefaultLogger logger = new DefaultLogger(); PrinterManager printerManager = new PrinterManager(logger, new PrinterRepository()); var epsonPrinter = new EpsonPrinter("123x"); var canonPrinter = new CanonPrinter("123x"); while (true) { var key = Console.ReadKey(); if (key.Key == ConsoleKey.D0) { printerManager.Add(epsonPrinter); } if (key.Key == ConsoleKey.D1) { printerManager.Add(canonPrinter); } if (key.Key == ConsoleKey.D2) { printerManager.Print(canonPrinter, @"D:\1.txt"); } if (key.Key == ConsoleKey.D3) { printerManager.Print(epsonPrinter, @"D:\1.txt"); } if (key.Key == ConsoleKey.E) { break; } } }
private static void CreatePrinter() { Console.WriteLine("Enter printer name"); string name = Console.ReadLine(); Console.WriteLine("Enter printer model"); string model = Console.ReadLine(); PrinterManager.Add(new Printer(model, name)); }
private static void CreatePrinter() { Console.WriteLine("Enter name of printer"); string name = Console.ReadLine(); Console.WriteLine("Enter model of printer"); string model = Console.ReadLine(); PrinterManager.Add(new Printer(name, model)); }
private static void CreatePrinter(this PrinterManager manager) { Console.WriteLine("Enter printer name"); string name = Console.ReadLine(); Console.WriteLine("Enter printer model"); string model = Console.ReadLine(); Printer printer = new Printer(name, model); manager.Add(printer); }
private static void CreatePrinter() { try { Console.WriteLine("Enter printer name"); string Name = Console.ReadLine(); Console.WriteLine("Enter printer model"); string Model = Console.ReadLine(); printerManager.Add(new Printer(Name, Model)); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } }
private static void CreatePrinter() { PrinterManager.Add(); }
private static void AddKnownPrinters(PrinterManager pm) { pm.Add(new CanonPrinter()); pm.Add(new EpsonPrinter()); }