Beispiel #1
0
 public void ShowAllInfo(int id)
 {
     try
     {
         displayMessage?.Invoke("#" + (surgeonList[id].Id + 1) + "      NAME: " + surgeonList[id].Name + "\t\tAGE: " + surgeonList[id].Age + "\n\tWORK EXPERIENCE: " + surgeonList[id].WorkExperience + "\tQUALIFICATION: " + surgeonList[id].Qualification);
         displayMessage?.Invoke("\n");
         displayMessage?.Invoke("Days of work: ");
         ScheduleMethods.ShowDaysOfWork(surgeonList[id].schedule);
         displayMessage?.Invoke("\n\t" + surgeonList[id].Name + "'s operations:\n");
         surgeonList[id].ShowAllOperations();
     }
     catch (System.ArgumentOutOfRangeException)
     {
         displayMessage?.Invoke("no surgeons with that index");
     }
 }
Beispiel #2
0
        public int PerformOperation()
        {
            int    result = -1;
            Random rnd    = new Random();


            displayMessage?.Invoke("What operation do u need to perform? ");
            string title = Console.ReadLine();

            displayMessage?.Invoke("Which doctor you want to choose? ");

            int id = 0;

            try
            {
                id = Int32.Parse(Console.ReadLine()) - 1;
            }

            catch (System.FormatException)
            {
                displayMessage?.Invoke("wrong input");
            }

            try
            {
                if (surgeonList[id].GetOperationPercentage(title) != -1)
                {
                    displayMessage?.Invoke("\nWhat day you want to choose?");
                    string day = Console.ReadLine();

                    if (ScheduleMethods.CheckAvailibility(day, surgeonList[id].schedule))
                    {
                        displayMessage?.Invoke("The doctor " + surgeonList[id].Name + " has " + surgeonList[id].GetOperationPercentage(title) * 100 + " % on success.\nDo u want to perform the operation?(1 - yes, 2 - no)  ");
                        int choice = 0;

                        try
                        {
                            choice = Int32.Parse(Console.ReadLine());
                        }

                        catch (System.FormatException)
                        {
                            displayMessage?.Invoke("wrong input");
                        }

                        if (choice == 1)
                        {
                            result = performOperation(id, title); // calling event to perform operation.
                        }

                        else if (choice == 0)
                        {
                            result = -1;
                        }

                        else
                        {
                            Console.WriteLine("wrong input");
                            result = -1;
                        }

                        return(result);
                    }
                    else
                    {
                        displayMessage?.Invoke($"{surgeonList[id].Name} rests on that day");
                        return(-3);
                    }
                }

                else
                {
                    displayMessage?.Invoke($"{surgeonList[id].Name} doesnt perform such operations");
                    return(-2);
                }
            }
            catch (System.ArgumentOutOfRangeException)
            {
                displayMessage?.Invoke("no doctors with that id");
                return(-2);
            }
        }