public static void Main() { Person female = new Person(); female = female.MakePerson(21); Person male = new Person(); male = male.MakePerson(22); Console.WriteLine(female); Console.WriteLine(male); }
public void CreatePerson(int age) { Person newPerson = new Person(); newPerson.Age = age; if (age % 2 == 0) { newPerson.Name = "Mr."; newPerson.Gender = PersonGender.male; } else { newPerson.Name = "Mrs."; newPerson.Gender = PersonGender.female; } }
public Person Generate(int generationSourceNumber) { Person person = new Person(); person.Age = generationSourceNumber; if (generationSourceNumber % 2 == 0) { person.Name = MaleName; person.Gender = Gender.Male; } else { person.Name = FemaleName; person.Gender = Gender.Female; } return person; }
public Person MakePerson(int age) { var person = new Person(); person.Age = age; int ageRemainder = age % 2; if (ageRemainder == 0) { person.Name = MaleName; person.Gender = Gender.Male; } else { person.Name = FemaleName; person.Gender = Gender.Female; } return person; }