static void Main(string[] args) { // Create an object from Person Persons myFriends = new Persons(); // create a Friend Person person1 = new Person { Firstname = "Jussi", Lastname = "Pietilä", SosialSecurityNumber = "251284-AA1"}; Person person2 = new Person { Firstname = "Matti", Lastname = "Puttonen", SosialSecurityNumber = "250665-BA1" }; Person person3 = new Person { Firstname = "Juuso", Lastname = "Joku", SosialSecurityNumber = "251290-AAA" }; //add person to Persons myFriends.AddPerson(person1); myFriends.AddPerson(person2); myFriends.AddPerson(person3); // print collection myFriends.PrintCollection(); // Get one person Console.WriteLine("Get one person"); Person person4 = myFriends.GetPerson(1); if (person4 != null) { Console.WriteLine(person4.ToString()); } else { Console.WriteLine("Cannot find person from that position"); } // Find person whit sotu string sosialSecurityNumber = "251290-AAA"; Console.WriteLine("Find person whit sotu: " + sosialSecurityNumber); Person person5 = myFriends.FindPerson(sosialSecurityNumber); 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 friends... Person person1 = new Person { FirstName = "Marke", LastName = "Boy", SocialSecurityNumber = "010101" }; Person person2 = new Person { FirstName = "Kalle", LastName = "Kekäle", SocialSecurityNumber = "020202" }; Person person3 = new Person { FirstName = "Pekka", LastName = "Pökäle", SocialSecurityNumber = "030303" }; // 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 = "010101"; 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 friends... Person person1 = new Person {Firstname = "Jussi", Lastname = "Jurkka", SocialSecurityNumber = "010101-01E6" }; Person person2 = new Person { Firstname = "Loska", Lastname = "Maaso", SocialSecurityNumber = "301235-06G8" }; Person person3 = new Person { Firstname = "Urpo", Lastname = "Karva", SocialSecurityNumber = "294371-12F9" }; // 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 = "010101-01E6"; 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 person1 = new Person { FirstName = "Jussi", LastName = "Jurkka", SocialSecurityNumber = "451348-123F" }; Person person2 = new Person { FirstName = "Jukka", LastName = "Jooseppi", SocialSecurityNumber = "452348-123A" }; Person person3 = new Person { FirstName = "Linda", LastName = "Erkkila", SocialSecurityNumber = "851348-123B" }; Person person4 = new Person { FirstName = "Paul", LastName = "Steiner", SocialSecurityNumber = "451348-123C" }; Person person5 = new Person { FirstName = "Tero", LastName = "Olafson", SocialSecurityNumber = "987654-123D" }; Person person6 = new Person { FirstName = "Antti", LastName = "Earthtribe", SocialSecurityNumber = "477778-123E" }; Person person7 = new Person { FirstName = "Olle", LastName = "Borgson", SocialSecurityNumber = "123546-123G" }; Person person8 = new Person { FirstName = "Aaaaa", LastName = "Aaaaa", SocialSecurityNumber = "451348-123H" }; // Add persons to collection myFriends.AddPerson(person1); myFriends.AddPerson(person2); myFriends.AddPerson(person3); myFriends.AddPerson(person4); myFriends.AddPerson(person5); myFriends.AddPerson(person6); myFriends.AddPerson(person7); myFriends.AddPerson(person8); // Print collection myFriends.PrintCollection(); // Get one person Console.WriteLine("Get one person from collection:"); Person person9 = myFriends.GetPerson(5); if (person9 != null) { Console.WriteLine(person9.ToString()); } else { Console.WriteLine("Cannot find person in that position..."); } // Find person with sotu Console.WriteLine("Get one person with sotu: 987654-123D..."); string socialSecurityNumber = "987654-123D"; myFriends.FindPerson(socialSecurityNumber); Person person10 = myFriends.FindPerson(socialSecurityNumber); if (person10 != null) { Console.WriteLine(person10.ToString()); } else { Console.WriteLine("Person with sotu not found..."); } }