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

def retrieveAddress: Option[Adress]  =  {
    // TODO: Implement  
    val s1 = Try(getStreet1)
    val s3 = Try(getStreet3)
    
    try{
        Adress(s1, s2.toOption, s3.toOption)
    }catch{
        e: RuntimeException => None 
    }
    
    /*
    if (s1.isSuccesed) {
        Adress(s1, Some(s2), Some(s3))
    }else{
        println(s1.getMessage) // getMessage
        None
    }
    */
    
}

// Caller
val a = retrieveAddress

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