static string GetCategoryByTask(TasksWithCategories collection, Task task) { string ret = ""; for (int i = 0; i < collection.fCategories.Count; i++) { if (collection.HasCategory(task, collection.fCategories[i])) { ret += string.Format("{0}{1}", (ret == "" ? "" : ", "), collection.fCategories[i].CategoryName); } } if (ret == "") { ret = "<None>"; } return(ret); }
public static TasksWithCategories GetTasksWithCategories() { TasksWithCategories ret = new TasksWithCategories(); Random rnd = new Random(); for (int i = 0; i < Tasks.MaxTasks; i++) { for (int j = 0; j < 1 + rnd.Next(Categories.MaxCategories); j++) { Category cat = ret.fCategories[rnd.Next(ret.fCategories.Count)]; if (!ret.HasCategory(ret.fTasks[i], cat)) { ret.List.Add(new Relation(ret.fTasks[i], cat)); } } } return(ret); }