Add to Widget a static field count and a constructor that increases it by one every time a widget is built.
A static field belongs to the class, not to any single object — all widgets share one counter. The program builds three widgets and prints 3.