public string PerformClone(Clone clone)
        {
            var cloneNumber  = CommandClones.Count + 1;
            var cloneOfClone = new Clone(new LinkedList <string>(clone.Programs), new LinkedList <string>(clone.RollBacks), cloneNumber);

            CommandClones.Add(cloneOfClone.Number, cloneOfClone);
            return(null);
        }
 public string PerformCheck(Clone clone)
 {
     if (clone.Programs.Count > 0)
     {
         return(clone.Programs.Last.Value);
     }
     return("basic");
 }
 public string PerformLearn(Clone clone, string program)
 {
     if (!clone.Programs.Contains(program))
     {
         clone.RollBacks.Clear();
         clone.Programs.AddLast(program);
     }
     return(null);
 }
 public string PerformRollBack(Clone clone)
 {
     if (clone.Programs.Count > 0)
     {
         clone.RollBacks.AddLast(clone.Programs.Last.Value);
         clone.Programs.RemoveLast();
     }
     return(null);
 }
Пример #5
0
        public Clone Cloning()
        {
            var clone = new Clone();

            clone.LearnedPrograms.Head  = LearnedPrograms.Head;
            clone.LearnedPrograms.Tail  = LearnedPrograms.Tail;
            clone.CanceledPrograms.Head = CanceledPrograms.Head;
            clone.CanceledPrograms.Tail = CanceledPrograms.Tail;
            return(clone);
        }
 public string PerformRelearn(Clone clone)
 {
     if (clone.RollBacks.Count > 0)
     {
         var rollBack = clone.RollBacks.Last.Value;
         clone.RollBacks.RemoveLast();
         clone.Programs.AddLast(rollBack);
     }
     return(null);
 }
        public Clone MakeCopy()
        {
            var cln = new Clone
            {
                LearnedProgramms    = LearnedProgramms,
                RollbackedProgramms = RollbackedProgramms,
                clonned             = true
            };

            this.clonned = true;
            return(cln);
        }
Пример #8
0
 void learn(int ID, string programID)
 {
     if (ID <= Clone.Count)
     {
         clones[ID - 1].Learn(programID);
     }
     else
     {
         var clone = new Clone(ID);
         clone.Learn(programID);
         clones.Add(clone);
     }
 }
Пример #9
0
        public string Execute(string query)
        {
            string command       = DecoderCommand(query);
            int    cloneIndex    = DecoderCommandCI(query);
            int    programmIndex = DecoderCommandPI(query);

            if (clonesList.Count < cloneIndex)
            {
                clonesList.Add(clone);
            }

            switch (command)
            {
            case "learn":
                clonesList[cloneIndex - 1].SkillsLearn(programmIndex);
                break;

            case "rollback":
                clonesList[cloneIndex - 1].RollBackMethod();
                break;

            case "relearn":
                clonesList[cloneIndex - 1].RelearnMethod();
                break;

            case "clone":
                Clone newClone = new Clone();
                if (clonesList[cloneIndex - 1].Skills.Count != 0)
                {
                    newClone.Skills.AddLast(clonesList[cloneIndex - 1].Skills.Last.Value);
                }
                if (clonesList[cloneIndex - 1].RollBack.Count != 0)
                {
                    newClone.RollBack.AddLast(clonesList[cloneIndex - 1].RollBack.Last.Value);
                }
                clonesList.Add(newClone);
                break;

            case "check":
                if (clonesList[cloneIndex - 1].Skills.Count == 0)
                {
                    return("basic");
                }
                else
                {
                    return(clonesList[cloneIndex - 1].Skills.Last.Value.ToString());
                }
            }

            return(null);
        }
Пример #10
0
        public Clone CreateClone()
        {
            var newClone = new Clone();

            if (programs.Count != 0)
            {
                newClone.programs.CopyLinkedStack(programs.PeekLastItem(), programs.Count);
            }
            if (rollbacks.Count != 0)
            {
                newClone.rollbacks.CopyLinkedStack(rollbacks.PeekLastItem(), rollbacks.Count);
            }
            return(newClone);
        }
Пример #11
0
        public string Execute(string query)
        {
            var v  = query.Split(' ');
            var op = v[0];
            var id = int.Parse(v[1]);

            if (op == "learn")
            {
                clones[id].Learn(v[2]);
            }
            else if (op == "rollback")
            {
                clones[id].Rollback();
            }
            else if (op == "relearn")
            {
                clones[id].Relearn();
            }
            else if (op == "clone")
            {
                clones[nextId++] = new Clone(clones[id]);
            }
            else if (op == "clone")
            {
                clones[nextId++] = new Clone(clones[id]);
            }
            else if (op == "check")
            {
                return(clones[id].GetCurrentProgram());
            }
            else
            {
                throw new ArgumentException("unknown operation: " + op);
            }
            return(null); // for all except Check
        }
Пример #12
0
 public Clone(Clone clone)
 {
     LearnedProgramms.Clone(clone.LearnedProgramms);
     RolledBackProgramms.Clone(clone.RolledBackProgramms);
 }
Пример #13
0
        private void NewClone(int id)
        {
            Clone newClone = new Clone(clones[id - 1]);

            clones.Add(newClone);
        }
Пример #14
0
            public void CloneItem(List <Clone> allClones)
            {
                Clone newClone = new Clone(new MyStack <int>(programs), new MyStack <int>(rollBackPrograms));

                allClones.Add(newClone);
            }
Пример #15
0
 //Клонировать клона
 public Clone(Clone cloneToCopy)
 {
     knowledge = new Stack(cloneToCopy.knowledge);
     history   = new Stack(cloneToCopy.history);
 }
Пример #16
0
 public Clone(Clone other)
 {
     learned = other.learned;
     undoes  = other.undoes;
 }
Пример #17
0
 public CloneVersionSystem()
 {
     clones[nextId++] = new Clone();
 }
Пример #18
0
 public Clone(Clone anotherClone)
 {
     learnedProgramms = new Stack(anotherClone.learnedProgramms);
     rollBackHistory  = new Stack(anotherClone.rollBackHistory);
 }
Пример #19
0
 public Clone(Clone a)
 {
     _clonePrograms   = a._clonePrograms.Clone();
     _rollbackHistory = a._rollbackHistory.Clone();
 }
Пример #20
0
 public Clone(Clone clone)
 {
     learningPrograms = new MyStack <string>(clone.learningPrograms.Count, clone.learningPrograms.Last);
     history          = new MyStack <string>(clone.history.Count, clone.history.Last);
 }
Пример #21
0
 public Clone(Clone clone)
 {
     LearnedProgramms    = clone.LearnedProgramms.CopySingleTypeStack();
     RolledBackProgramms = clone.RolledBackProgramms.CopySingleTypeStack();
 }
Пример #22
0
 public Clone(Clone anotherClone)
 {
     learnedCommandHistory = new Stack <int>(anotherClone.learnedCommandHistory.Reverse());
     rollbackHistory       = new Stack <int>(anotherClone.rollbackHistory.Reverse());
 }