AccountIntake is the preimplemented driver for registration, password reset, and bulk import. It delegates those operations to AccountWorkflows, which is the class you will refactor.
All three workflows use the same password policy. A valid password:
8;The starter AccountWorkflows predates the last rule and contains three copies of the older validation logic. Refactor it by introducing a PasswordPolicy and make every workflow delegate to that single policy. Do not modify AccountIntake or any public method signature.
AccountIntake supports these operations:
AccountIntake() creates an empty service with a minimum password length of 8.boolean setMinimumLength(int length) sets the minimum and returns true. Values outside 4 through 20 change nothing and return false.int minimumLength() returns the current minimum.String createAccount(String username, String password) returns "INVALID_PASSWORD", "DUPLICATE", or "REGISTERED". Password validation happens before the duplicate check.String resetPassword(String username, String password) returns "UNKNOWN_USER", "INVALID_PASSWORD", or "RESET". Account existence is checked first.String importAccount(String username, String password) returns "INVALID_PASSWORD", "DUPLICATE", or "IMPORTED". Password validation happens before the duplicate check.int accountCount() returns the number of accepted usernames.Passwords contain only ASCII characters. Password persistence is outside this exercise; the class records accepted usernames only.
Input:
Output:
Explanation: "Alice9safe" contains "alice" when case is ignored. The second password satisfies the shared policy.
Input:
Output:
Explanation: Registration, import, and reset all consult the same policy object, including its updated minimum length.
1 <= username.length <= 201 <= password.length <= 40-100 <= length <= 100100 calls will be made across all methods.The starter contains complete legacy workflows but predates the username-exclusion rule. Refactor AccountWorkflows while adding that rule once in PasswordPolicy; keep the provided AccountIntake driver unchanged.
Full marks when registration, reset and import all delegate password decisions to one PasswordPolicy object. Lose points heavily when length, uppercase, digit or username checks appear in more than one workflow.
Full marks when the policy enforces the current minimum length, an uppercase ASCII letter, a digit and case-insensitive exclusion of the username. Lose points when the new rule is added to only some paths or a minimum-length change does not affect all three.
Full marks when AccountWorkflows owns account existence and status results, PasswordPolicy owns only validation, and the provided AccountIntake driver remains unchanged. Lose points for plaintext password storage, duplicated account checks, printing to stdout or changing the required status precedence.
Passing every test is not enough on its own. A submission is accepted only when the design also clears the bar.
| Call | Returns |
|---|---|
| new AccountIntake() | null |
| createAccount("alice", "Alice9safe") | "INVALID_PASSWORD" |
| createAccount("alice", "Secure9!") | "REGISTERED" |
| accountCount() | 1 |
The first password contains the username when case is ignored. The second satisfies the shared policy and creates the account.
Run checks these cases. Submit also runs a larger hidden set.

