Preparing your design workspace

Loading the problem and your saved attempt…

Design and Implement a Task and Worker Assignment Model

Model explicit task-to-worker assignment, completion and stable status output with guarded lifecycle transitions.

Design and implement a small system using Task and Worker classes, then invoke them to produce the required output.

For this exercise, assume one operator makes sequential calls in one in-memory process. The operator registers tasks and workers with non-empty, case-sensitive string IDs; IDs are unique within their respective kinds. The operator explicitly chooses both the task and the worker for each assignment.

A task begins PENDING, may be assigned once to an available worker, and then becomes ASSIGNED. Each worker can have at most one active task. Completing an assigned task makes it DONE and releases its worker for another pending task. A completed task retains the identity of the worker that completed it.

Reject unknown IDs, duplicate registration, assignment of a non-pending task, assignment to a busy worker, and completion of a task that is not assigned. A rejected operation must leave all state unchanged.

Return a status summary as value data: tasks ordered lexicographically by task ID with their state and assigned/completing worker ID (or no worker yet), and workers ordered lexicographically by worker ID with their active task ID (or none). Reading a summary must not let callers change the system's state.

Choose the responsibility and interface boundaries, explain an assignment and completion journey plus an invalid operation, and implement the central behavior.

There is no requirement for automatic scheduling, timers, priorities, dependency graphs, background threads, heartbeats, failover, persistence, or external task execution. The final checkpoint introduces an explicitly separate practice extension; it does not change this core contract.