class FamilyMember extends AnyRef
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.
- Alphabetic
- By Inheritance
- FamilyMember
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new FamilyMember(name: String)
Initializes a new, childless
FamilyMember
. - new FamilyMember(name: String, children: Vector[FamilyMember])
- name
the person's name
- children
the person's children
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- val children: Vector[FamilyMember]
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def everyoneBelow: Vector[FamilyMember]
Returns all the people in the family tree from this
FamilyMember
downwards, including thisFamilyMember
.Returns all the people in the family tree from this
FamilyMember
downwards, including thisFamilyMember
. That is, the returned collection contains this person and their descendants. - final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def isChildless: Boolean
Returns
true
if and only if the person has no children. - final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def mostChildren: FamilyMember
Returns the person in the family tree from this
FamilyMember
downwards (this person included) that has the largest number of children.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. In case of a tie, the method will return 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.
- val name: String
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def numberOfChildren: Int
Returns the number of children the person has.
- def numberOfDescendants: Int
Returns the number of descendants the person has in total.
Returns the number of descendants the person has in total. A person's descendants are that person's children plus all their descendants.
- def numberOfDescendantsAt(generation: Int): Int
Returns the number of descendants the
FamilyMember
has in a particular generation (not above, not below).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.- generation
a positive number of "steps" that identifies a generation
- 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.
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.
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString: String
Returns a string representation of the person.
Returns a string representation of the person.
- Definition Classes
- FamilyMember → AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated @deprecated
- Deprecated
(Since version ) see corresponding Javadoc for more information.