Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            People myPeople = new People();

            Person Bob = new Person();
            Bob.Name = "Bob";
            Bob.Age = 32;

            Person Sally = new Person();
            Bob.Name = "Sally";
            Bob.Age = 64;

            //myPeople.add(new Person("Bob", 32));

            foreach (int age in myPeople.Ages)
            {

                Console.WriteLine(age);

            }

            char x = 'a';

            Console.WriteLine(x);

            Console.ReadKey();
        }
Ejemplo n.º 2
0
        public object Clone()
        {
            People ClonedPeople = new People();
            Person currentPerson, newPerson;

            foreach (DictionaryEntry p in Dictionary)
            {

                currentPerson = p.Value as Person;
                newPerson = new Person();
                newPerson.Name = currentPerson.Name;
                newPerson.Age = currentPerson.Age;

                ClonedPeople.add(newPerson);

            }

            return ClonedPeople;
        }
Ejemplo n.º 3
0
        //Other Methods
        public Person[] GetOldest()
        {
            Person oldestPerson = null;
            People oldestPeople = new People();
            Person currentPerson;

            foreach (DictionaryEntry p in Dictionary)
            {

                currentPerson = p.Value as Person;

                if (oldestPerson == null)
                {
                    oldestPerson = currentPerson;
                    oldestPeople.add(oldestPerson);
                }
                else
                {
                    if (currentPerson > oldestPerson)
                    {
                        oldestPeople.Clear();
                        oldestPeople.add(currentPerson);
                        oldestPerson = currentPerson;
                    }
                    else
                    {
                        if (currentPerson >= oldestPerson)
                        {
                            oldestPeople.add(currentPerson);
                        }
                    }
                }

            }

            Person[] oldestPeopleArray = new Person[oldestPeople.Count];
            int copyIndex = 0;

            foreach (DictionaryEntry p in oldestPeople)
            {
                oldestPeopleArray[copyIndex] = p.Value as Person;
                copyIndex++;
            }

            return oldestPeopleArray;
        }
Ejemplo n.º 4
0
 //add
 public void add(Person newPerson)
 {
     Dictionary.Add(newPerson.Name, newPerson);
 }