Refactor a DeviceHub without changing its observable behavior.
The starter uses one large OfficeDevice interface containing printing, scanning, faxing, and three support flags. Basic devices are forced to provide methods they cannot use, so they fill those methods with "UNSUPPORTED" placeholders.
Split that interface into focused capabilities:
addPrinter(), addScanner(), and addAllInOne() add a device and return its index.canPrint(index), canScan(index), and canFax(index) report the capabilities recorded for that device.printDoc(index, document) returns "PRINTED: <document>" when supported.scan(index) returns "SCANNED" when supported.fax(index, number) returns "FAXED TO <number>" when supported."UNSUPPORTED".The legacy starter already produces the required outputs. Your task is structural: remove unused methods from device classes while preserving behavior.
Full marks when printing, scanning, and faxing are separate interfaces and each device implements only the capabilities it supports. Lose points heavily when one interface still declares every operation or classes contain placeholder methods.
Full marks when DeviceHub records and invokes capabilities without checking device names or storing boolean support flags. Lose points for kind switches, casts to BasicPrinter or AllInOne, or duplicated operation logic in the hub.
Full marks when indexes remain stable, capability queries agree with actions, unsupported and invalid requests return UNSUPPORTED, and action strings are exact. Lose points for exceptions or printed output.
Passing every test is not enough on its own. A submission is accepted only when the design also clears the bar.
| Call | Returns |
|---|---|
| new DeviceHub() | null |
| addPrinter() | 0 |
| canPrint(0) | true |
| canScan(0) | false |
| printDoc(0, "report.pdf") | "PRINTED: report.pdf" |
| scan(0) | "UNSUPPORTED" |
A basic printer exposes only the printing capability.
Run checks these cases. Submit also runs a larger hidden set.

