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?
1 answer
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.
|
Можно как-то сделать вывод рандомного массива с цифрами от 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