---
# 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: String,
  street3: Option[String]
)


def retrieveAddress: Option[Address] = {
    // TODO: Implement
    val street1:Option[String] = Try(getStreet1).toOption
    val street2:Option[String] = Try(getStreet2).toOption
    val street3:Option[String] = Try(getStreet3).toOption
    street1.map(s1 => Address(s1,street2,street3))
}

sealed trait Error
case object UnableGetStreet1 extends Error
case object UnableGetStreet2 extends Error


def retrieveAddress2: Either[NonEmptySet[Error], Address] = {
    ???
}

// Caller
val address = retrieveAddress2
address match {
    case Left(UnableGetStreet1) => 
    case Left(Set()) => ???
    
}

// =======================================================================  
// 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