示例#1
0
 private void ShowScoutActivities(Scout scout)
 {
     List<String> scoutActivities;
     Boolean exit = false;
     int action;
     while (!exit)
     {
         scoutActivities = TypeScoutActivities(scout);
         Console.Write("Enter a number in accordance to your choice: ");
         Int32.TryParse(Console.ReadLine(), out action);
         if (action <= 0 || action > scoutActivities.Count + 2)
         {
             Console.WriteLine("Wrong input.");
             Console.WriteLine("Press any key to continue.");
             Console.ReadKey();
         }
         else if (action > 0 && action <= scoutActivities.Count)
         {
             try
             {
                 scout.RemoveActivity(scoutActivities[action - 1]);
             }
             catch (Exception e)
             {
                 Console.WriteLine(e.Message);
                 Console.WriteLine("Press any key to continue.");
                 Console.ReadKey();
             }
         } else if (action == scoutActivities.Count + 1)
         {
             AddNewScoutActivity(scout, scoutActivities);
         } else
         {
             exit = true;
         }
     }
 }
示例#2
0
 private List<String> TypeScoutActivities(Scout scout)
 {
     List<String> scoutActivities;
     Console.Clear();
     Console.WriteLine("Work with activities > {0,-30}\n", scout.Name);
     scoutActivities = scout.PrintActivities();
     Console.WriteLine("\n{0,4}. Add an activity", scoutActivities.Count + 1);
     Console.WriteLine("{0,4}. Exit\n", scoutActivities.Count + 2);
     if (scoutActivities.Count > 0)
     {
         Console.WriteLine("Enter a number form 1 to {0} to remove an activity.", scoutActivities.Count);
     }
     return scoutActivities;
 }
示例#3
0
 private void AddNewScoutActivity(Scout scout, List<String> scoutActivities)
 {
     List<String> activities;
     Boolean exit = false;
     int activity = 0;
     Byte score = 0;
     if (scout is BoyScout)
     {
         activities = BoyScout.FilterBoysActivities(scoutActivities);
     }
     else
     {
         activities = GirlScout.FilterGirlsActivities(scoutActivities);
     }
     if (activities.Count > 0)
     {
         Console.WriteLine("\nAdding new activity.");
         for (int i = 0; i < activities.Count; i++)
         {
             Console.WriteLine("{0,4}. {1,-50}", i + 1, activities[i]);
         }
         while (!exit)
         {
             Console.Write("Enter a number to add activity: ");
             Int32.TryParse(Console.ReadLine(), out activity);
             if (activity > 0 && activity <= activities.Count)
             {
                 exit = true;
             }
             else
             {
                 Console.WriteLine("Wrong input.");
                 Console.Write("Press any key to continue.");
             }
         }
         exit = false;
         while (!exit)
         {
             Console.Write("Enter a score for the activity (1 - 100): ");
             Byte.TryParse(Console.ReadLine(), out score);
             if (score > 0 && score <= 100)
             {
                 exit = true;
             }
             else
             {
                 Console.WriteLine("Wrong input.");
                 Console.Write("Press any key to continue.");
             }
         }
         try
         {
             if (scout is BoyScout)
             {
                 ((BoyScout)scout).AddActivity(activities[activity - 1], score);
             }
             else
             {
                 ((GirlScout)scout).AddActivity(activities[activity - 1], score);
             }
         }
         catch (Exception e)
         {
             Console.WriteLine(e.Message);
             Console.Write("Press any key to continue.");
             Console.ReadKey();
         }
     }
     else
     {
         Console.WriteLine("All possible activities are added.");
         Console.WriteLine("Press any key to continue.");
         Console.ReadKey();
     }
 }