It is necessary to implement the generation of work schedule for the current month. There are, for example, 8 workers. It is necessary that everyone at least 1 time worked on a day off, the rest of the working days on weekdays. Those. It is required to display the calendar for the current month and randomly fill it with when someone works. How to display a calendar is understandable, in principle, even how to determine randomly when someone works - I understand about it. The question is, is it possible to assign some IDE for each cell of the calendar? To force to display data in this cell. Or should you just draw the table for each month yourself? Is it possible to somehow make a conclusion of a random array with numbers from 1 to 8, with a repetition of not more than 5 times for each digit?

  • 3
    Можно как-то сделать вывод рандомного массива с цифрами от 1 до 8, с повторением не больше 5 раз для каждой цифры? it's easy. For example, create a list in which to lay each number from 1 to 8 5 times and then make Collection.shuffle. - pavel
  • one
    if you want to assign a unique id, then use java.util.UUID for cell objects - abbath0767
  • Is id = "20160425" (April 25, 2016) not unique enough for a calendar? - Sergey Mitrofanov
  • The question was not what ID to come up with for the cell, but how to assign it, in principle, to the calendar cell. - batman
  • one
    @batman uh ... kto.get (0)? - pavel

1 answer 1

Add a UUID field to the class responsible for your cell. This will be a great identifier for your purposes.

 public class yourCell { ... public UUID uuid; public yourCell(...) { ... uuid = UUID.randomUUID(); } ... } 

You can implement, as advised @Sergey Mitrofanov - generating an identifier depending on the date.