You are given a program that models drivers communicating over a hardware bus.
The current design is incorrect because:
Your task is to fix the design without changing the behavior or output.
What the Program Must Achieve (End Goal):
BusBusWhat Is Given to You:
What You Must Change (Very Explicit):
Driver must NOT inherit from BusDriver must contain or reference a BusIn short:
Replace inheritance with composition so the bus can be shared.
Program Flow:
BusDriver objects using the same BusInput:
Four integers
addr1 val1
addr2 val2
Output (Exact Order):
Bus ready
Driver started
Driver started
Bus write: <addr1> <val1>
Bus write: <addr2> <val2>
Driver stopped
Driver stopped
Bus stopped
Constraints:
Bus object may existBus must NOT be created inside DriverDriver must NOT expose write() directly
Input
10 20 30 40
Expected Output
Bus ready Driver started Driver started Bus write: 10 20 Bus write: 30 40 Driver stopped Driver stopped Bus stopped