public void addEvent(String pathNameX, String EventNameX, DateTime endTimeX) { if (firstPath == null) { Console.WriteLine("There are not paths"); } else { PS = firstPath; pathNode pathToAddTo = null; while (PS.getNextPath() != null) { if (PS.getPathName().Equals(pathNameX)) { pathToAddTo = PS; } PS = PS.getNextPath(); } if (pathToAddTo == null) { Console.WriteLine("That path does not exsist"); } else { pathToAddTo.getEvents().addEvent(EventNameX, endTimeX); M.debug("Event added"); } } }
public void addTimer(String pathNameX, String timerNameX, String medNameX) { medNode medToAdd = null; medToAdd = medMaster.findMed(medNameX); if (medToAdd == null) { Console.WriteLine("That medication does not exsist"); } else { if (firstPath == null) { Console.WriteLine("There are not paths"); } else { PS = firstPath; pathNode pathToAddTo = null; while (PS.getNextPath() != null) { if (PS.getPathName().Equals(pathNameX)) { pathToAddTo = PS; } PS = PS.getNextPath(); } if (pathToAddTo == null) { Console.WriteLine("That path does not exsist"); } else { pathToAddTo.getTimers().addTimer(timerNameX, medToAdd, pathToAddTo.getPathName()); M.debug("Med added"); } } } }
public void startEvent(string pathNameX) { if (firstPath == null) { Console.WriteLine("No paths exist"); } else { PS = firstPath; while (PS.getNextPath() != null) { if (PS.getPathName().Equals(pathNameX)) { PS.getEvents().startEvent(); } } } }
public void editPath(String pathName) { if (firstPath != null) { //If firstPath == null there are no paths PS = firstPath; pathNode toEdit = null; while (PS.getNextPath() != null) { if (PS.getPathName().Equals(pathName)) { //Finding the first path with that name, storing it, and breaking out of the loop toEdit = PS; break; } PS = PS.getNextPath(); } if (toEdit == null) { //No path by that name Console.WriteLine("There is no path by that name. Please make sure it was spelt correctly, this is Case Sensative"); } else { //The path was found Console.WriteLine("What would you like to do in path " + pathName + "?"); M.BL(); Console.WriteLine("1) Edit the Path's name"); Console.WriteLine("2) Edit the timer set in Path " + pathName); M.BL(); ConsoleKeyInfo answer = Console.ReadKey(); M.BL(); M.BL(); switch (answer.KeyChar) { case '1': { toEdit.changePathName(pathName); break; } case '2': { Console.WriteLine("What timer would you like to edit?"); M.BL(); M.BL(); toEdit.getTimers().printTimers(); string timerToEdit = Console.ReadLine(); toEdit.getTimers().editTimer(timerToEdit); M.BL(); break; } default: { Console.WriteLine("that is not an option"); M.BL(); break; } } } } else { Console.WriteLine("There are no paths to Edit. Please Create some First"); } }
public void removePath(String pathNameToRemove) { pathNode toRemove = null; if (firstPath != null) //if FP == null then there are no paths { PS = firstPath; while (PS.getNextPath() != null) { if (PS.getPathName().Equals(pathNameToRemove)) { toRemove = PS; //finding the first path with this name and exiting loop break; } PS = PS.getNextPath(); //incriment loop } if (toRemove == null) { Console.WriteLine("There was no Path With that Name. Pleaes make sure it was spelled correctly, this is Case sensative"); //No path found with proper nam } else { M.BL(); Console.WriteLine("Are you Sure you want to remove path " + pathNameToRemove + "?"); //Double checking can't hurt Console.WriteLine("This CANNOT be undone"); Console.WriteLine("Y/N"); M.BL(); ConsoleKeyInfo answer = Console.ReadKey(); //Reading answer M.BL(); switch (answer.KeyChar) { case 'y': //making sure this works for either case { Console.WriteLine("Removing path " + pathNameToRemove + "."); removePath(toRemove); break; } case 'Y': //making sure this works for either case { Console.WriteLine("Removing path " + pathNameToRemove + "."); removePath(toRemove); break; } default: { Console.WriteLine("Cancling remove operation, returning to menu"); break; } } } } else { Console.WriteLine("There are no paths to remove, please add some, so I can remove them"); } }