Esempio n. 1
0
        public List <ArithmeticTask> RandomTasks(ArithmeticTaskRequest request, int count)
        {
            List <ArithmeticTask> item = tasks.FilterByRequest(request).Shuffle().Take(count)
                                         .ToList();

            return(item);
        }
Esempio n. 2
0
        public static IEnumerable <ArithmeticTask> FilterByRequest(this IEnumerable <ArithmeticTask> tasks,
                                                                   ArithmeticTaskRequest request)
        {
            tasks = tasks.Where(x =>
            {
                bool match = true;
                if (!request.AllowTimes1)
                {
                    match = match && x.A != 1;
                }

                if (!request.AllowTimes0)
                {
                    match = match && x.A != 0;
                }

                match = match && request.Tables.Contains(x.B);

                return(match);
            });


            return(tasks);
        }
Esempio n. 3
0
        public ArithmeticTask RandomTask(ArithmeticTaskRequest request)
        {
            ArithmeticTask item = tasks.FilterByRequest(request).ToList().RandomItem();

            return(item);
        }
Esempio n. 4
0
 public List <ArithmeticTask> AllForTable(ArithmeticTaskRequest request)
 {
     return(tasks.FilterByRequest(request).ToList());
 }