Create a static factory method that keeps track of the instances created.
With a private constructor, the users have to use the factory method, which can then throw the exception if more than 5 objects have already been created.
Давай предположим. Что тебе дали 2 задания. 1) Написать конструктор. 2) Написать в конструкторе логику. с первым пунктом тыс правился, а вот со вторым - ты все не видишь свой цикл for