---
# System prepended metadata

title: Question

---

# Question
Implement the function `retrieveAddress` using the methods `getStreet1`, `getStreet2`, and `getStreet3` to create an `Address`.
```scala
case class Address(
  street1: String,
  street2: Option[String],
  street3: Option[String]
)



// Try 

def tryOption[A](f: => A) = {
    Try(f).toOption
}

def tryOption[A](f: => A) = {
    Try(f).toEither
}

    
sealed trait Result
case class Failure(errors: NonEmptyList[Throwable]) extends Result
case class PartialSuccess(errors: List[Throwable], address: Address) extends Result
case class Success(address: Address) extends Result


def retrieveAddress: Either[Throwable, Address] = {
    tryEither(getStreet1)
    .map(Address(_, tryOption(getStreet2), tryOption(getStreet3)))
}
// =======================================================================  
// LIBRARY METHODS 
// =======================================================================
/**
  * Retrieves the main street address.
  * @throws RuntimeException if empty
  */
def getStreet1: String = {
  // implementation
}
/**
  * Retrieves additional street address line 2.
  * @throws RuntimeException if empty
  */
def getStreet2: String = {
  // implementation
}
/**
  * Retrieves additional street address line 3.
  * @throws RuntimeException if empty
  */
def getStreet3: String = {
  // implementation
}