Refactor a TextPipeline that applies transformations in insertion order.
The starter stores step names and branches inside apply. Uppercase and prefix work, but the newly requested reverse step is ignored. Introduce a text-step contract so later transformations extend the pipeline instead of modifying it.
addUppercase() adds a step that uppercases the running text.addPrefix(prefix) adds a step that places prefix before the running text. An empty prefix is valid.addReverse() adds a step that reverses the running text.stepCount() returns the number of steps. Duplicate steps are allowed.apply(text) runs all steps in insertion order and returns the result.Full marks when apply loops over TextStep-style objects and contains no kind switch or concrete-type check. Lose points heavily when reverse or another future step requires editing apply.
Full marks when addStep accepts any transform implementation and the three public helpers delegate to it. Lose points for parallel kind/value collections or a factory switch inside the pipeline.
Full marks when steps run in insertion order, duplicates are allowed, prefixes may be empty, reverse handles empty text, and stepCount is accurate. Lose points for reordering, skipped steps, 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 TextPipeline() | null |
| addPrefix("hi ") | true |
| addUppercase() | true |
| apply("sam") | "HI SAM" |
| stepCount() | 2 |
Prefix runs before uppercase because insertion order is part of the pipeline.
Run checks these cases. Submit also runs a larger hidden set.

