Skip to content

Instantly share code, notes, and snippets.

@NRBPerdijk
Last active April 30, 2019 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NRBPerdijk/4c64c4966621cbd6567b39e15208bc47 to your computer and use it in GitHub Desktop.
Save NRBPerdijk/4c64c4966621cbd6567b39e15208bc47 to your computer and use it in GitHub Desktop.
/*
* Our Domain object functions as a factory for our domain-related classes.
* It has methods that create new instances of these classes, which can then safely be used from another Context.
*/
class Domain {
def weatherForecastList(): WeatherForecastList = WeatherForecastList(List())
def percentage(percent: Int): Percentage = Percentage(percent: Double)
def chanceOfRain(chance: Percentage): ChanceOfRain = ChanceOfRain(chance: Percentage)
def temperature(degrees: Int, temperatureScale: String): Temperature =
Temperature(degrees: Int, temperatureScale: String)
def windSpeed(scale: String, speed: Int): WindSpeed =
WindSpeed(scale: String, speed: Int)
def windForecast(windSpeed: WindSpeed, direction: String): WindForecast =
WindForecast(windSpeed: WindSpeed, direction: String)
def weatherForecast(
humidity: Percentage,
windForecast: WindForecast,
sunshine: Percentage,
temperature: Temperature,
chanceOfRain: ChanceOfRain): WeatherForecast =
WeatherForecast(humidity, windForecast, sunshine, temperature, chanceOfRain)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment