honeytrap.devexercisesfactory-method.javaSettings
Description

6. Factory Method

EasyCreational1 hidden requirement

Letting the subclass decide which product gets made, instead of the base class guessing

Dialog renders a button, and both dialogs render the right one. The tests pass.

It works that out by asking itself what subclass it is — so Dialog, the general thing, has a list of every specific thing that will ever extend it.

WindowsDialog and WebDialog already have a createButton() that answers exactly this question. Rewrite Dialog so it asks instead of guessing.

Run compiles every file and runs Tests.java — the tests you can read.

Submit runs those again, then applies 1 requirement you have not seen, one at a time.

Your code is never edited. Each requirement is added to the project as it stands. If the design is right, nothing you wrote has to change.

  • Ctrl/⌘ + Enter runs the tests