Family Docs
Fall 2026
API

# FamilyMember

o1.family.FamilyMember
class FamilyMember(val `name`: String, val `children`: Vector[FamilyMember])

The class `FamilyMember` represents people in a very simple family tree analysis program. Each person has a name and zero or more children. A `FamilyMember` object is immutable.

Note: All the methods in this class assume that each descendant descends from a person via a single line of ancestry only.

## Parameters

children

  the person’s children

name

  the person’s name

## Attributes

Graph
Supertypes
  class Object
  trait Matchable
  class Any

## Members list

### Value members

#### Constructors

def this(`name`: String)

Initializes a new, childless `FamilyMember`.

Initializes a new, childless `FamilyMember`.

## Attributes

#### Concrete methods

def everyoneBelow: Vector[FamilyMember]

Returns all the people in the family tree from this `FamilyMember` downwards, including this `FamilyMember`. That is, the returned collection contains this person and their descendants.

Returns all the people in the family tree from this `FamilyMember` downwards, including this `FamilyMember`. That is, the returned collection contains this person and their descendants.

## Attributes

def isChildless: Boolean

Returns `true` if and only if the person has no children.

Returns `true` if and only if the person has no children.

## Attributes

def mostChildren: FamilyMember

Returns the person in the family tree from this `FamilyMember` downwards (this person included) that has the largest number of children. (Only immediate descendants count as children.) If called on a childless person, returns that person. If there is a tie, the method returns one of the tied people.

Returns the person in the family tree from this `FamilyMember` downwards (this person included) that has the largest number of children. (Only immediate descendants count as children.) If called on a childless person, returns that person. If there is a tie, the method returns one of the tied people.

Consider an example family tree:

- Odin has one child: Edie.
- Edie has five children: Molly, Barbara, Calvin, Sam, and Walter.
- Sam has three children: Dawn, Gus, and Greg.
- Dawn has three children: Lewis, Milton, and Edith.

This means that:

- Called on Odin, the method returns Edie, since she has five children; more than her parent Odin and more than any of her own descendants.
- Called on Edie, the method returns Edie herself, for the same reason.
- Called on Molly, the method returns Molly herself, even though she has no children.
- Called on Sam, the method may return either Sam himself or Sam’s daughter Dawn, both of whom have three children.

## Attributes

def numberOfChildren: Int

Returns the number of children the person has.

Returns the number of children the person has.

## Attributes

def numberOfDescendants: Int

Returns the number of descendants the person has in total. A person’s descendants are that person’s children plus all their descendants.

Returns the number of descendants the person has in total. A person’s descendants are that person’s children plus all their descendants.

## Attributes

def numberOfDescendantsAt(`generation`: Int): Int

Returns the number of descendants the `FamilyMember` has in a particular generation (not above, not below). A generation is defined here as a number of “steps” that indicates how far removed a set of descendants is from their ancestor. For example, a person’s children form a generation at step 1, the person’s grandchildren constitute another generation at step 2, the greatgrandchildren at step 3, and so on.

Returns the number of descendants the `FamilyMember` has in a particular generation (not above, not below). A generation is defined here as a number of “steps” that indicates how far removed a set of descendants is from their ancestor. For example, a person’s children form a generation at step 1, the person’s grandchildren constitute another generation at step 2, the greatgrandchildren at step 3, and so on.

## Parameters

generation

  a positive number of “steps” that identifies a generation

## Attributes

Returns

  the number of descendants that are exactly the indicated number of steps removed from the person in the family tree

def numberOfDescendingGenerations: Int

Returns the number of generations below this person in the family tree. For a person with no children, this will be zero; for someone with at least one child but no grandchildren, this will be one; for someone with grandchildren but no greatgrandchildren, this will be two, and so on.

Returns the number of generations below this person in the family tree. For a person with no children, this will be zero; for someone with at least one child but no grandchildren, this will be one; for someone with grandchildren but no greatgrandchildren, this will be two, and so on.

## Attributes

override def toString: String

Returns a string representation of the person.

Returns a string representation of the person.

## Attributes

Definition Classes
  Any

#### Concrete fields

val children: Vector[FamilyMember]
val name: String