static void Main(string[] args) { // create an object from Persons Persons myFriends = new Persons(); // create a friends... Person person1 = new Person { Firstname = "Mikko", Lastname = "Mallikas", SocialSecurityNumber = "010101-010E" }; Person person2 = new Person { Firstname = "Henkka", Lastname = "Mäkinen", SocialSecurityNumber = "123456-111T" }; Person person3 = new Person { Firstname = "Laura", Lastname = "Joulunen", SocialSecurityNumber = "987456-456H" }; // 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(1); if (person4 != null) { Console.WriteLine(person4.ToString()); } else { Console.WriteLine("Cannot find person in that position..."); } // find person with sotu string socialSecurityNumber = "123456-111T"; Console.WriteLine("Find person with sotu : " + socialSecurityNumber); Person person5= myFriends.FIndPerson(socialSecurityNumber); if (person5 != null) { Console.WriteLine(person5.ToString()); } else { Console.WriteLine("Not found..."); } }
static void Main(string[] args) { // create an object from Persons Persons myFriends = new Persons(); // create a few friends... Person friend1 = new Person { Firstname = "Jussi", Lastname = "Jurkka", SocialSecurityNumber = "010101-01E6" }; Person friend2 = new Person { Firstname = "Minna", Lastname = "Kuikka", SocialSecurityNumber = "121212-90L6" }; Person friend3 = new Person { Firstname = "Anna", Lastname = "Liukko", SocialSecurityNumber = "091216-753E8" }; // add person to collection myFriends.AddPerson(friend1); myFriends.AddPerson(friend2); myFriends.AddPerson(friend3); // print collection myFriends.PrintCollection(); // get a person Console.WriteLine("\nGet a person from the collection: "); Person friend4 = myFriends.GetPerson(1); if (friend4 != null) { Console.WriteLine(friend4.ToString()); } else { Console.WriteLine("Position doesn't hold a person."); } // find person with socialsecuritynumber string socialSecurityNumber = "020101-01E6"; Console.WriteLine("\nFind person with SocialSecurityNumber: "); Person friend5 = myFriends.FindPerson(socialSecurityNumber); if (friend5 != null) { Console.WriteLine(friend5.ToString()); } else { Console.WriteLine("No person with such SocialSecurityNumber."); } }
static void Main(string[] args) { // ceate an object from Persons Persons myFrinds = new Persons(); // create few frinds Person person1 = new Person { Firstname = "Jussi", Lastname = "Jurkka", SocialSecurityNumber = "010101-01E6" }; Person person2 = new Person { Firstname = "Tuomas", Lastname = "Veturi", SocialSecurityNumber = "123666-1337" }; Person person3 = new Person { Firstname = "Liisa", Lastname = "Tuomio", SocialSecurityNumber = "060606-9939" }; // add persons to collection myFrinds.AddPerson(person1); myFrinds.AddPerson(person2); myFrinds.AddPerson(person3); // print collection myFrinds.PrintCollection(); // get one person Console.WriteLine("Get one person from collection:"); Person person4 = myFrinds.Getperson(1); if (person4 != null) { Console.WriteLine(person4.ToString()); } else { Console.WriteLine("Cannot find person in that position"); } //find person with sotu string socialSecurityNumber = "010101-01E6"; Person person5 = myFrinds.FindPerson(socialSecurityNumber); Console.WriteLine("Find person with sotu:"); if(person5 != null) { Console.WriteLine(person5.ToString()); } else { Console.WriteLine("Cannot find person with that sotu"); } }
static void Main(string[] args) { // create an object from Persons Persons myFriends = new Persons(); // create a friends... Person person1 = new Person { Firstname = "Jussi", Lastname = "Jurkka", SocialSecurityNumber = "020202-123A" }; Person person2 = new Person { Firstname = "Jukka", Lastname = "Jurkka", SocialSecurityNumber = "123456+987B" }; Person person3 = new Person { Firstname = "Juuso", Lastname = "Jurkka", SocialSecurityNumber = "010203-456C" }; // add persons to collection myFriends.AddPerson(person1); myFriends.AddPerson(person2); myFriends.AddPerson(person3); // print collection myFriends.PrintCollection(); // get one person Console.WriteLine("Get on person from friends"); Person person4 = myFriends.GetPerson(1); if (person4 != null) { Console.WriteLine(person4.ToString()); } else { Console.WriteLine("Cannot find person in that position..."); } // find person with SSN string socialSecurityNumber = "010203-456C"; myFriends.FindPerson(socialSecurityNumber); Person person5 = myFriends.FindPerson(socialSecurityNumber); if (person5 != null) { Console.WriteLine(person5.ToString()); } else { Console.WriteLine("Not found...") } }
static void Main(string[] args) { // create an object from Persons Persons myFriens = new Persons(); // create a friends... Person person1 = new Person { Firstname = "Jussi", Lastname = "Jurkka", SocialSevurityNumber = "010101-016E" }; Person person2 = new Person { Firstname = "Minna", Lastname = "Husso", SocialSevurityNumber = "020202-012R" }; Person person3 = new Person { Firstname = "Ankka", Lastname = "Sorsa", SocialSevurityNumber = "030303-013T" }; Person person7 = new Person { Firstname = "Jaakko", Lastname = "Kalle", SocialSevurityNumber = "030306-013T" }; // add persons to collection myFriens.AddPerson(person1); myFriens.AddPerson(person2); myFriens.AddPerson(person3); // print collection myFriens.PrintCollection(); // get one person Console.WriteLine("Get one person from collection:"); Person person4 = myFriens.GetPerson(0); if (person4 != null) { Console.WriteLine(person4.ToString()); }else { Console.WriteLine("Cannot find person in that postition..."); } // find person with sotu string socialSecurityNumber = "010101-01E6"; Console.WriteLine("Find person with sotu : " + socialSecurityNumber); Person person5 = myFriens.FindPerson(socialSecurityNumber); if (person5 != null) { Console.WriteLine(person5.ToString()); }else { Console.WriteLine("Not found..."); } }
static void Main(string[] args) { // create an object from Persons Persons myFriends = new Persons(); // create a friends... Person person1 = new Person { Firstname = "Jussi", Lastname = "Jurkka", SocialSecurityNumber = "010101-011E" }; Person person2 = new Person { Firstname = "Onni", Lastname = "Ojansuu", SocialSecurityNumber = "222222-022Q" }; Person person3 = new Person { Firstname = "Aatu", Lastname = "Virtanen", SocialSecurityNumber = "131213-133Y" }; // 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 person in that position..."); } // find person with sotu string socialSecurityNumber = "222222-022Q"; Console.WriteLine("Find person with sotu :" + socialSecurityNumber); Person person5 = myFriends.FindPerson(socialSecurityNumber); if (person5 != null) { Console.WriteLine(person5.ToString()); } else { Console.WriteLine("Not found..."); } }
/// <summary> /// Adds a person to collection. /// </summary> /// <param name="person">Added person</param> public void AddPerson(Person person) { persons.Add(person); }