A computer starts through three small subsystems: the power supply comes on, the system drive mounts, and the network connects. A facade gives callers one startup operation and one safe reverse-order shutdown operation.
Implement only the ComputerFacade class:
String[] startComputer() powers on, mounts the disk, and connects the network. It returns a header, the three subsystem responses, and a footer in that order.String[] shutDown() disconnects the network, unmounts the disk, and powers off. It returns a header, the three subsystem responses, and a footer in that order.String setNetwork(boolean connected) connects or disconnects by delegating to the network adapter.String setDisk(boolean mounted) mounts or unmounts by delegating to the disk drive.boolean powerOn(), boolean diskMounted(), and boolean networkConnected() query the corresponding subsystem.int startupCount() returns how many times startComputer has run.
The supplied PowerSupply, DiskDrive, and NetworkAdapter classes, along with the public FacadeDriver test harness, are complete in the starter code. Implement only ComputerFacade; do not modify the supplied types. The examples use FacadeDriver operations because that is the class the tests instantiate. The operations are idempotent: asking an already-on device to turn on returns the same line and keeps it on.
Example 1:
Input:
Output:
Example 2:
Input:
Output:
Constraints
- At most
100 calls are made across all methods.
Starter Code
Only ComputerFacade is unfinished. The supporting subsystem classes and FacadeDriver test harness are pre-implemented; do not modify them.