Example #1
0
        static void Main(string[] args)
        {
            PersonHashCode PHC = new PersonHashCode();
            

            Person alex = new Person("Olexandr", "Bohuslavskyi", 27);
            Person olex = new Person("Olexandr", "Bohuslavskyi", 29);
            Person Ken = new Person("Ken", "Block", 38);
            Person ass = new Person("Ken", "Block", 38);
            Person Homer = new Person("Homer", "Simpson", 64);

            PHC.Add(alex);
            PHC.Add(olex);
            PHC.Add(Ken);
            PHC.Add(ass);
            PHC.Add(Homer);



            Console.WriteLine(Homer.GetHashCode());
            Console.WriteLine(alex.GetHashCode());
            Console.WriteLine(olex.GetHashCode());
            Console.WriteLine(Ken.GetHashCode());
            Console.WriteLine(ass.GetHashCode());
            Console.WriteLine(PHC.Size());
            Console.ReadLine();
        }
Example #2
0
 public Person(string fName, string lName, int age)
 {
     this.id = ++ID;
     this.FirstName = fName;
     this.LastName = lName;
     this.Age = age;
     this.next = null;
 }
Example #3
0
 public void Add(Person newPerson)
 {
     if (Table[newPerson.GetHashCode()] == null)
     {
         List<Person> p = new List<Person>();
         p.Add(newPerson);
         Table[newPerson.GetHashCode()] = p;
     }
     else
     {
         if (!Table[newPerson.GetHashCode()].Contains(newPerson))
         {
             Table[newPerson.GetHashCode()].Add(newPerson);
         }
     }
 }