Design a ComputerWorkshop that builds and scraps computers. Every computer creates and owns exactly three parts: a CPU, a RAM module, and a 512 GB disk.
The provided ComputerWorkshop class supports these operations:
ComputerWorkshop() creates a workshop holding no computers.int build(String cpuModel, int cores, int ramGb) assembles a computer from those specs and returns the id it was stored at. Every computer also gets a 512 GB disk, which no argument describes.int computerCount() returns how many computers exist.int partCount() returns how many parts exist across all computers. Each computer has exactly three.String describe(int id) returns "CPU: <model> (<cores> cores) | RAM: <ramGb> GB | Disk: 512 GB", or "SCRAPPED" when no computer has that id.boolean scrap(int id) destroys that computer and returns true, or returns false when no computer has that id. Its parts go with it.Ids are assigned in build order starting at 0 and are never reused. Scrapping a computer removes its three parts with it, because those parts have no independent lifecycle.
Your task is to implement Cpu, Ram, Disk, and Computer as expected by the provided workshop. Do not modify ComputerWorkshop. Each part should describe itself, and Computer must construct its own parts from the supplied specifications rather than receive prebuilt components.
Input:
Output:
Explanation: Building the computer creates its CPU and RAM from the supplied specifications and adds the default 512 GB disk. The computer combines the three part descriptions.
Input:
Output:
Explanation: Two computers own six parts in total. Scrapping computer 0 removes that computer and its three parts, leaving one computer with three parts.
1 <= cpuModel.length <= 201 <= cores <= 128 and 1 <= ramGb <= 1024100 calls will be made across all methods.Full marks when a computer creates its own CPU, RAM and disk inside its constructor from the specs it was given, and there is no way to supply, replace or retrieve a part from outside. Lose points heavily when parts are passed into the computer, or when the workshop creates them and hands them over.
Full marks when scrapping a computer removes its parts along with it, so the part count always equals three times the computer count. Lose points when scrapped parts survive, when the part count is tracked in its own field, or when a scrapped computer still describes itself.
Full marks for separate part types each describing themselves, a computer that assembles their descriptions, and an unknown id handled deliberately. Lose points when the description is built entirely inside the computer or workshop, or for printing to stdout.
Passing every test is not enough on its own. A submission is accepted only when the design also clears the bar.
| Call | Returns |
|---|---|
| new ComputerWorkshop() | null |
| build("i7", 8, 16) | 0 |
| computerCount() | 1 |
| partCount() | 3 |
| describe(0) | "CPU: i7 (8 cores) | RAM: 16 GB | Disk: 512 GB" |
Building one computer creates its three parts, and describing it reports all three.
Run checks these cases. Submit also runs a larger hidden set.

