Client · showPreview
Calls render() through TextView
—Appearance
DECORATOR / PRACTICE
You met Decorator through notification senders. Now compose optional extras around a text preview.
YOUR MISSION / TEXT PREVIEWS
A preview starts with “hello”. Some callers want a label, some want uppercase, and some want both. Keep the client calling render() while setup chooses the wrappers and their order.
Each layer receives text from its inner object, then adds its own behavior. Test both orders and add a border. This is object composition, not @decorator syntax.
01 / DESIGN A WRAPPER
Both LabelText and UppercaseText use your choices. Keep the contract, delegate, then add an extra.
Try your own design first. Hints and retries are unlimited.
02 / WRAP · CALL · RETURN
LabelText(PlainText) should add Note: to hello.
Calls travel down. Each layer returns text back up.
Calls render() through TextView
—Adds “Note: ” after its inner object returns
—Supplied object · owns the original “hello”
—Original object rendered 0 times so far.
Start a trace to test your selected wrappers. Matching text alone does not prove correct delegation.
Each test uses a fresh chain. Back replays recorded events. Changing a design choice clears all verification.
03 / EXTEND THE CHAIN
Add BorderText outside the uppercase-and-label chain. It should turn NOTE: HELLO into [NOTE: HELLO]. Which edits are needed?
First finish passing traces for the label and both wrapper orders with the same assembly.
No timer and no attempt limit. Try another assembly, use a hint, or reveal the answer when it helps.