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);
 }
Esempio n. 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);
        }
Esempio n. 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);
     }
 }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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
        }
Esempio n. 12
0
 public Clone(Clone clone)
 {
     LearnedProgramms.Clone(clone.LearnedProgramms);
     RolledBackProgramms.Clone(clone.RolledBackProgramms);
 }
Esempio n. 13
0
        private void NewClone(int id)
        {
            Clone newClone = new Clone(clones[id - 1]);

            clones.Add(newClone);
        }
Esempio n. 14
0
            public void CloneItem(List <Clone> allClones)
            {
                Clone newClone = new Clone(new MyStack <int>(programs), new MyStack <int>(rollBackPrograms));

                allClones.Add(newClone);
            }
Esempio n. 15
0
 //Клонировать клона
 public Clone(Clone cloneToCopy)
 {
     knowledge = new Stack(cloneToCopy.knowledge);
     history   = new Stack(cloneToCopy.history);
 }
Esempio n. 16
0
 public Clone(Clone other)
 {
     learned = other.learned;
     undoes  = other.undoes;
 }
Esempio n. 17
0
 public CloneVersionSystem()
 {
     clones[nextId++] = new Clone();
 }
 public Clone(Clone anotherClone)
 {
     learnedProgramms = new Stack(anotherClone.learnedProgramms);
     rollBackHistory  = new Stack(anotherClone.rollBackHistory);
 }
Esempio n. 19
0
 public Clone(Clone a)
 {
     _clonePrograms   = a._clonePrograms.Clone();
     _rollbackHistory = a._rollbackHistory.Clone();
 }
Esempio n. 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);
 }
Esempio n. 21
0
 public Clone(Clone clone)
 {
     LearnedProgramms    = clone.LearnedProgramms.CopySingleTypeStack();
     RolledBackProgramms = clone.RolledBackProgramms.CopySingleTypeStack();
 }
Esempio n. 22
0
 public Clone(Clone anotherClone)
 {
     learnedCommandHistory = new Stack <int>(anotherClone.learnedCommandHistory.Reverse());
     rollbackHistory       = new Stack <int>(anotherClone.rollbackHistory.Reverse());
 }