Answer the question
In order to leave comments, you need to log in
How to implement a category for collection items?
Good afternoon, dear development gurus,
I'm trying to write a simple program for maintaining a to-do list. confused at the moment how best to model in the program the concept of a category for each of the tasks. in tax managers that I tried to use, usually each task can be assigned more than one category.
while thinking about the option to write down the category through the enumeration (enum). but enum seems to be able to store only integer values, not strings,
I will be grateful for your hints on how to do this
Answer the question
In order to leave comments, you need to log in
Hello.
Read about enum here . So you will understand that you are wrong about integer values. If you store categories as an enum, you will automatically close the user the ability to add their own categories. If this possibility is not needed, then enum can also be used. To store multiple categories in a task, you can add a Set of Categories to the task class.
Well, if you suddenly use the database in the application. Then you can make a table with categories, a table with tasks, and between them a link table to link tasks and categories.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question