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); }
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); }
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); } }
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); }
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); }
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 }
public Clone(Clone clone) { LearnedProgramms.Clone(clone.LearnedProgramms); RolledBackProgramms.Clone(clone.RolledBackProgramms); }
private void NewClone(int id) { Clone newClone = new Clone(clones[id - 1]); clones.Add(newClone); }
public void CloneItem(List <Clone> allClones) { Clone newClone = new Clone(new MyStack <int>(programs), new MyStack <int>(rollBackPrograms)); allClones.Add(newClone); }
//Клонировать клона public Clone(Clone cloneToCopy) { knowledge = new Stack(cloneToCopy.knowledge); history = new Stack(cloneToCopy.history); }
public Clone(Clone other) { learned = other.learned; undoes = other.undoes; }
public CloneVersionSystem() { clones[nextId++] = new Clone(); }
public Clone(Clone anotherClone) { learnedProgramms = new Stack(anotherClone.learnedProgramms); rollBackHistory = new Stack(anotherClone.rollBackHistory); }
public Clone(Clone a) { _clonePrograms = a._clonePrograms.Clone(); _rollbackHistory = a._rollbackHistory.Clone(); }
public Clone(Clone clone) { learningPrograms = new MyStack <string>(clone.learningPrograms.Count, clone.learningPrograms.Last); history = new MyStack <string>(clone.history.Count, clone.history.Last); }
public Clone(Clone clone) { LearnedProgramms = clone.LearnedProgramms.CopySingleTypeStack(); RolledBackProgramms = clone.RolledBackProgramms.CopySingleTypeStack(); }
public Clone(Clone anotherClone) { learnedCommandHistory = new Stack <int>(anotherClone.learnedCommandHistory.Reverse()); rollbackHistory = new Stack <int>(anotherClone.rollbackHistory.Reverse()); }