Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            //create an object from Persons
            Persons myFriends = new Persons();


            //create a few people...
            Person person1 = new Person { FirstName = "Santeri", LastName = "Suo", SSN = "230593-215D" };
            Person person2 = new Person { FirstName = "Jorma", LastName = "Suo", SSN = "230594-216D" };
            Person person3 = new Person { FirstName = "Jaska", LastName = "Jokunen", SSN = "140296-315E" };

            // add persons to collection
            myFriends.AddPerson(person1);
            myFriends.AddPerson(person2);
            myFriends.AddPerson(person3);

            //print collection
            myFriends.PrintCollection();

            //get one person from collection
            Console.WriteLine("Get one person from collection: ");

            Person person4 = myFriends.GetPerson(100);
            if (person4 != null)
            {
                Console.WriteLine(person1.ToString());
            } else
            {
                Console.WriteLine("Can not find person in that position");
            }


            //find person with SNN
            string ssn = "140296-315E";

            Console.WriteLine("Find person with SSN");
            Person person5 = myFriends.FindPerson(ssn);
            if (person5 != null)
            {
                Console.WriteLine(person5.ToString());
            }
                else
            {
                Console.WriteLine("Not Found");
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            // create an object from Persons
            Persons myFriends = new Persons();

            // Create a friends...
            Person person1 = new Person { Firstname = "Juissi", Lastname = "Perse", SocialSecurityNumber = "011101-01E3" };
            Person person2 = new Person { Firstname = "Van", Lastname = "Mainen", SocialSecurityNumber = "910101-0AE3" };
            Person person3 = new Person { Firstname = "Keijo", Lastname = "Kalja", SocialSecurityNumber = "310101-0XD1" };
            Person person4 = new Person { Firstname = "Paska", Lastname = "Kasa", SocialSecurityNumber = "012101-0163" };

            // add persons to collection
            myFriends.AddPerson(person1);
            myFriends.AddPerson(person2);
            myFriends.AddPerson(person3);

            // print collection
            myFriends.PrintCollection();

            //get one person
            Console.WriteLine("Get one person from collection:");
          Person person5 = myFriends.GetPerson(1);
            if (person5 != null)
            {
                Console.WriteLine(person5.ToString());
            }
            else
            {
                Console.WriteLine("Cannot find person in that position....");
            }

            //Find person with sotu
            string socialSecurityNumber = "011101-01KAKKAE3";
            Console.WriteLine("Find person with sotu:");
            Person person6 = myFriends.FindPerson(socialSecurityNumber);
            if (person6 != null)
            {
                Console.WriteLine(person6.ToString());
            }
            else
            {
                Console.WriteLine("Not found...");
            }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            //create an object from Persons
            Persons myFriends = new Persons();

            //create persons...
            Person person1 = new Person { FirstName = "Jussi", LastName = "Jurkka", SocialNumber = "010101-0155" };
            Person person2 = new Person { FirstName = "Make", LastName = "Toiso", SocialNumber = "120527-1657" };
            Person person3 = new Person { FirstName = "Tiia", LastName = "Lappala", SocialNumber = "210205-1112" };

            //add persons to collection
            myFriends.AddPerson(person1);
            myFriends.AddPerson(person2);
            myFriends.AddPerson(person3);

            //print collection
            myFriends.PrintCollection();

            //get one person
            Console.WriteLine("Get one person from collection: ");
            Person person4 = myFriends.GetPerson(0);
            if(person4 != null)
            {
                Console.WriteLine(person4.ToString());
            }
            else
            {
                Console.WriteLine("Cannot find a person from that position");
            }

            //find person with sotu
            string socialNumber = "120527-1657";
            Console.WriteLine("Searching person with sotu: ");
            Person person5 = myFriends.FindPerson(socialNumber);
            if (person5 != null)
            {
                Console.WriteLine(person5.ToString());
            }
            else
            {
                Console.WriteLine("Couldn't find anything");
            }
        }