Design and refactor a ProjectDashboard that reports progress for several projects.
Each project owns its tasks. A task has a title, a completed flag, and an archived flag. Archived tasks are historical records: they do not count toward progress and cannot be completed.
The dashboard exposes these operations:
createProject(name) stores an empty project and returns its id.addTask(projectId, title, completed, archived) asks that project to add a task and returns the task id, or -1 for an unknown project.completeTask(projectId, taskId) returns false for an unknown project, unknown task, or archived task. Otherwise, it marks the task complete and returns true.progress(projectId) returns "<name>: <completed>/<active>", excluding archived tasks from both numbers, or "UNKNOWN".projectCount() returns the number of projects.The legacy starter exposes each project's task collection. The dashboard indexes tasks, changes their flags, and calculates progress itself. Because it reaches past the project, it misses the archived-task rule.
Refactor the design so the dashboard talks to projects, and projects own every operation involving their task collection.
Input:
Output:
Explanation: The archived task stays inside the project but does not participate in current progress.
Input:
Output:
Explanation: The dashboard delegates the update and the query to the project that owns the tasks.
1 <= name.length, title.length <= 40100 calls will be made across all methods.The starter compiles, but getTasks turns the project's internal structure into dashboard knowledge and lets archived behavior be bypassed.
Full marks when Project owns its task list and ProjectDashboard never retrieves or indexes that collection. Lose points heavily for getTasks, tasks properties or dashboard code that loops over Task objects.
Full marks when the dashboard delegates add, complete and progress operations to Project, while archived-task decisions remain inside Project or Task. Lose points when the dashboard checks archived or completed flags itself.
Full marks when archived tasks are excluded from progress and cannot be completed, invalid ids are handled exactly, and successful operations preserve stable ids. Lose points for printing to stdout or returning mutable internals.
Passing every test is not enough on its own. A submission is accepted only when the design also clears the bar.
| Call | Returns |
|---|---|
| new ProjectDashboard() | null |
| createProject("Alpha") | 0 |
| addTask(0, "Build", false, false) | 0 |
| addTask(0, "Old plan", true, true) | 1 |
| progress(0) | "Alpha: 0/1" |
| completeTask(0, 1) | false |
| progress(0) | "Alpha: 0/1" |
| projectCount() | 1 |
Archived tasks are neither counted nor mutable through the dashboard.
Run checks these cases. Submit also runs a larger hidden set.

