Ejemplo n.º 1
0
        public bool TryGetCurrentState(int id, out List <List <int> > state)
        {
            List <List <int> > result = (List <List <int> >) new List <List <int> >();
            HanoiExecution     exe    = null;

            if (_solvers.ContainsKey(id))
            {
                result.Add(_solvers[id].FistPeg.ToList());
                result.Add(_solvers[id].SecondPeg.ToList());
                result.Add(_solvers[id].ThirdPeg.ToList());
                state = result;
                return(true);
            }
            else
            {
                exe = _exeRepository.Get(id);
                if (exe != null && exe.EndTime != null)
                {
                    result.Add(new List <int>());
                    result.Add(new List <int>());
                    var discList = Enumerable.Range(1, exe.DiscsNumber);
                    result.Add(discList.ToList());
                    state = result;
                    return(true);
                }
            }
            state = null;
            return(false);
        }
Ejemplo n.º 2
0
        public HanoiExecution Get(int id)
        {
            HanoiExecution ex  = null;
            HanoiLog       log = _context.Logs.Where(l => l.LogId == id).FirstOrDefault();

            if (log != null)
            {
                ex = new HanoiExecution()
                {
                    HanoiExecutionId = log.LogId,
                    CreationTime     = log.CreationTime,
                    DiscsNumber      = log.DiscsNumber,
                    EndTime          = log.EndTime
                };
            }
            return(ex);
        }