コード例 #1
0
 public void startFirstTimer()
 {
     if (firstTimer.getRunning() != true)
     {
         firstTimer.startTimer(true);
         firstTimer.setRunning(true);
     }
     else
     {
         Console.WriteLine("The first timer is alraedy running");
     }
 }
コード例 #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;
                        }
                        }
                    }
                }
            }
        }