Member

class Member(val id: Int, val name: String, val yearOfBirth: Int, val yearOfDeath: Option[Int])

Each instance of class Member represents an individual person, recorded by an (imaginary) society-membership app. A member has a number of basic attributes such as a name and a year of birth.

Once created, a Member object is immutable; to represent changes in a person, one should create a new instance of the class.

Value parameters:
id

a number that uniquely identifies the member from other members of the society

name

the member’s name

yearOfBirth

the year the member was born

yearOfDeath

the year the member died (wrapped in an Option; None if the member is alive)

class Object
trait Matchable
class Any

Value members

Concrete methods

Returns a Boolean value indicating whether the member is alive or not. That is, returns true if the member does not have a year of death,* and false if they do.

Returns a Boolean value indicating whether the member is alive or not. That is, returns true if the member does not have a year of death,* and false if they do.

override def toString: String

Returns a compact string description of the member. The description of a dead person has the form "Name(YoB-YoD)"; e.g. "Elvis(1935-1977)". The description of a living person is the same but with no year of death; e.g., "Madonna(1958-)".

Returns a compact string description of the member. The description of a dead person has the form "Name(YoB-YoD)"; e.g. "Elvis(1935-1977)". The description of a living person is the same but with no year of death; e.g., "Madonna(1958-)".

Definition Classes

Concrete fields

val id: Int