---
# 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]
)

case class AddressNotFoundException(msg: String, exception: Exception) extends RunTimeException
def retrieveAddress: Either[AddressNotFoundException, Address] = {

    Try(getStreet1) match {
        case Success(street1) => Right(Address(street1, Try(getStreet2).toOption, Try(getStreet3).toOption))
        case Failure(exception) => Left(AddressNotFoundException("Street1 is missing", exception))
    }
}


// =======================================================================  
// JAVA LIBRARY METHODS 
// =======================================================================
/**
  * Retrieves the main street address.
  * @throws RuntimeException if empty
  */
def getStreet1: String
/**
  * Retrieves additional street address line 2.
  * @throws RuntimeException if empty
  */
def getStreet2: String
/**
  * Retrieves additional street address line 3.
  * @throws RuntimeException if empty
  */
def getStreet3: String