예제 #1
0
        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");
                    }
                }
            }
        }
예제 #2
0
        public void editTimer(string timerToEdit)
        {
            timerNode toEdit = null;

            if (firstTimer != null) //if FT == null then there are no paths
            {
                TS = firstTimer;

                while (TS.getNextTimer() != null)
                {
                    if (TS.getTimerName().Equals(timerToEdit))
                    {
                        toEdit = TS; //finding the first path with this name and exiting loop
                        break;
                    }
                    TS = TS.getNextTimer(); //incriment loop
                }

                if (toEdit == null)
                {
                    Console.WriteLine("There was no timers with this name. Please make sure it was spelt correctly, this is case sensative");
                }

                else
                {
                    if (toEdit.getRunning() == true)
                    {
                        Console.WriteLine("You can't edit a running timer");
                    }

                    else
                    {
                        Console.WriteLine("What part of the timer would you Like to Edit");
                        Console.WriteLine("1) Linked Medication");
                        Console.WriteLine("2) Timer Name");
                        M.BL();
                        ConsoleKeyInfo answer = Console.ReadKey();
                        M.BL();
                        switch (answer.KeyChar)
                        {
                        case '1':
                        {
                            Console.WriteLine("What medication would you like to change to (Enter Name)");
                            M.BL();
                            medMaster.printMeds();

                            string medToChangeTo = Console.ReadLine();
                            toEdit.setMed(medMaster.findMed(medToChangeTo));
                            break;
                        }

                        case '2':
                        {
                            Console.WriteLine("What would you like to change the name to be?");
                            M.BL();
                            string newName = Console.ReadLine();
                            toEdit.setTimerName(newName);
                            break;
                        }

                        default:
                        {
                            Console.WriteLine("This is not an option");
                            break;
                        }
                        }
                    }
                }
            }
        }