---
# 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(getStreet2) match {
    case Success(street2) =>
    case Failure(exception) =>
}

Try(getStreet2).toOption

case class EmptyStreetError(message: String)

def retrieveAddress: Either[EmptyStreetError, Adress] = {
    Try(getStret1) match {
        case Failure(_) => None
        case Success(street1) =>
            Just(Adress(street1,
                Try(getStreet2) match {
                    case Failure(_) => None
                    case Success(s2) => Just(s2)
                },
                 Try(getStreet3) match {
                    case Failure(_) => None
                    case Success(s3) => Just(s3)
                },
            ))
    }
   )
}



// =======================================================================  
// LIBRARY METHODS — NO NEED TO IMPLEMENT THESE
// =======================================================================

/**
  * Retrieves the main street address.
  * @throws RuntimeException if empty
  */
def getStreet1: String = {
  // implementation
  
}

/**
  * Retrieves additional street address line 2.
  * @throws RuntimeException if empty or unable to get address
  */
def getStreet2: String = {
  // implementation
}

/**
  * Retrieves additional street address line 3.
  * @throws RuntimeException if empty or unable to get address
  */
def getStreet3: String = {
  // implementation
}

```