Exemplo n.º 1
0
        public void removeTimer(String timerNameToRemove)
        {
            timerNode toRemove = null;

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

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

                if (toRemove == null)
                {
                    Console.WriteLine("There was no Timers 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 Timer " + timerNameToRemove + "?"); //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 timer " + timerNameToRemove + ".");
                        removeTimer(toRemove);
                        break;
                    }

                    case 'Y':     //making sure this works for either case
                    {
                        Console.WriteLine("Removing timer " + timerNameToRemove + ".");
                        removeTimer(toRemove);
                        break;
                    }

                    default:
                    {
                        Console.WriteLine("Cancling remove operation, returning to menu");
                        break;
                    }
                    }
                }
            }

            else
            {
                Console.WriteLine("There are no timers to remove, please add some, so I can remove them");
            }
        }
Exemplo n.º 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;
                        }
                        }
                    }
                }
            }
        }