public class Document {
}
public interface IMachine {
void Print(Document d);
void Scan(Document d);
void Fax(Document d);
}
public class MultiFunctionPrinter : IMachine {
public void Print(Document d) {}
public void Scan(Document d) {}
public void Fax(Document d) {}
}
public class OldFashionPrinter : IMachine {
public void Print(Document d) {}
public void Scan(Document d) {
throw new System.NotImplementedException();
}
public void Fax(Document d) {
throw new System.NotImplementedException();
}
}
public interface IPrinter {
void Print(Document d);
}
public interface IScanner {
void Scan(Document d);
}
public class Photocopier : IPrinter, IScanner {
public void Print(Document d) {}
public void Scan(Document d) {}
}
public interface IMultiFunctionDevice : IScanner, IPrinter {}
public class MultiFunctionMachine : IMultiFunctionDevice {
private IPrinter _printer;
private IScanner _scanner;
public MultiFunctionMachine(IPrinter printer, IScanner scanner) {
if (printer == null)
throw new System.ArgumentNullException(paramName: nameof(printer));
if (scanner == null)
throw new System.ArgumentNullException(paramName: nameof(scanner));
this._printer = printer;
this._scanner = scanner;
}
public void Print(Document d) {
_printer.Print(d);
}
public void Scan(Document d) {
_scanner.Scan(d);
}
}
public class Program {
public static void Main() {}
}