package social

class SimpleUser(
    override val userName: String,
    override val yearOfBirth: Int,
    override val bio: String,
) : User{
    private val friends: MutableList<User> = mutableListOf()
    override val currentFriends
        get() = friends.map { it }

    override fun hasFriend(user: User) = friends.contains(user)

    override fun removeFriend(user: User) = friends.remove(user)

    override fun considerFriendRequest(user: User) =
        if (friends.contains(user)) false
        else true.also { friends.add(user) }

    override fun removeLongestStandingFriend() =
        if (friends.removeFirst())

    init {
        if (yearOfBirth !in 1900..2100)
            throw IllegalArgumentException("Year of birth must be between 1900 and 2100")
    }
}