예제 #1
0
 /// <summary>
 /// entering user information
 /// </summary>
 public void AddUsers()
 {
     try
     {
         Console.WriteLine("Input first name  ");
         string userFirstName = Console.ReadLine();
         Console.WriteLine("Input last name  ");
         string userLastName = Console.ReadLine();
         Console.WriteLine("Input gender(woman or man) ");
         string userGender = Console.ReadLine();
         Console.WriteLine("Input age  ");
         int userAge = Int32.Parse(Console.ReadLine());
         users.Add(new User(userFirstName, userLastName, userGender, userAge));
         if (FindNamesakes(userLastName).Count > 1)
         {
             NamesakesEventArgs args = new NamesakesEventArgs();
             args.Namesakes = FindNamesakes(userLastName);
             OnOutputNamesakes(args);
         }
     }
     catch (FormatException)
     {
         throw new FormatException("Wrong number format");
     }
 }
예제 #2
0
        static void WriteAndOutputNamesakes(object sender, NamesakesEventArgs e)
        {
            Console.WriteLine("Namesakes:");
            foreach (User namesake in e.Namesakes)
            {
                Console.WriteLine(namesake);
            }
            JSON_FileWriter writer = new JSON_FileWriter();

            writer.WriteToLsonFile(e.Namesakes, "C:\\Users\\Lenovo\\Source\\Repos\\NewRepo\\HomeTask8\\HomeTask8\\Users.json");
        }
예제 #3
0
        protected virtual void OnOutputNamesakes(NamesakesEventArgs ev)
        {
            EventHandler <NamesakesEventArgs> handler = OutputNamesakes;

            handler(this, ev);
        }