Search code examples
c#objectparent

How do I use a class parents and children?


I have a Object called Person and I need to have values decided by other classes or objects, one of them will be whether the Object person is a boy or girl and the two classes will give back variables like average body weight for example. How do i accomplish this?


Solution

  • You need to give your "Person" a couple attributes

    either bool isBoy or string(Enum?) Gender

    as well as float bodyWeight or similar.

    Then you need to make a list of Person, and get the Average of each persons bodyWeight

    you can also search through this list to find where the person isBoy or gender matches boy or girl