using System; using System.Collections.Generic; using System.Text; using SimplePrinter; namespace SimplePrinter { class TestSimplePrinter { static void Main(string[] args) { //******************************************************* // TestSimplePrinter.A: create a new printer object //******************************************************* Printer myPrinter = new Printer(Printer.PrinterEnum.Laser, Printer.AttachmentEnum.LAN | Printer.AttachmentEnum.Parallel | Printer.AttachmentEnum.USB); //******************************************************* // TestSimplePrinter.B: test for the printer type //******************************************************* switch (myPrinter.Type) { case Printer.PrinterEnum.DotMatrix : Console.WriteLine("Uses printer ribbons"); break; case Printer.PrinterEnum.Inkjet : Console.WriteLine("Uses ink cartridges"); break; case Printer.PrinterEnum.Laser : Console.WriteLine("Uses toner cartridges"); break; case Printer.PrinterEnum.Line : Console.WriteLine("Use 1403-style ribbons"); break; case Printer.PrinterEnum.Thermal : Console.WriteLine("Uses special paper"); break; default: Console.WriteLine("Other type of printer"); break; } //******************************************************* // TestSimplePrinter.C: test for the attachment type(s) //******************************************************* if ((myPrinter.Attachment & Printer.AttachmentEnum.BlueTooth) != 0) { Console.WriteLine("Supports Bluetooth"); } if ((myPrinter.Attachment & Printer.AttachmentEnum.LAN) != 0) { Console.WriteLine("Supports LAN"); } if ((myPrinter.Attachment & Printer.AttachmentEnum.Parallel) != 0) { Console.WriteLine("Supports Parallel"); } if ((myPrinter.Attachment & Printer.AttachmentEnum.USB) != 0) { Console.WriteLine("Supports USB"); } if (myPrinter.Attachment == 0) { Console.WriteLine("Supports [unknown]"); } Console.ReadLine(); } } }