Task: Game room. Prepare a game room for children of different age groups. Toys should be a fixed quantity within the allocated amount of money. There should be toys of related groups, for example: small, medium and large cars, dolls, balls, cubes.

It is necessary to use the PLO as much as possible, I think to create an abstract "playroom" class, inherit classes from it, for example, "junior group", etc., then create a collection variable in these rooms, where I will place toys, and a constant "budget ", toys, in turn, will contain a price field. Can you tell how you can improve all this, improve?

  • It seems to me that you need to make an abstract class (interface) a toy and from it inherit all the other toys in the integer field to contain its budget. And let the classroom playroom contain an array of pointers to the common ancestor of toys. Here you have polymorphism, inheritance, aggregation, encapsulation, and abstractness. - user31238
  • And then in this array to take toys from different groups and read their budget from the total number of the budget. As the total allocated budget ends, the toys in the room will be recruited - user31238
  • Well, another thing :) That's right, but it would be nice to provide a hierarchy of classes in toys (the task directly hints at this). For example, `class machine extends Toy {@override public double getPrice () {...} @override public boolean canBibic () {} ...} - m. vokhm

0