public Person AddWomanChild() { string name = StringCommand.SetPersonName(); int age = StringCommand.SetPersonAge(); Person womanChild = new Woman(name, age); if (root == null) { root = womanChild; } else { lastPerson.Child = womanChild; } lastPerson = womanChild; return(lastPerson); }
public Person AddHusband(List <Person> personList) { if (personList.Count > 0) { var person = StringCommand.GetPersonById(personList); var woman = person as Woman; bool flag = true; while (flag) { if (!(woman == null) && !StringCommand.ChecSpouse(personList, woman)) { string name = StringCommand.SetPersonName(); int age = StringCommand.SetPersonAge(); woman.Husband = new Man(name, age) { Child = woman.Child }; flag = false; } else { StringCommand.PrintColorMessage("Error!\n"); Console.ReadKey(); return(null); } } return(woman.Husband); } else { Console.WriteLine("Error."); return(null); } }