Created
July 16, 2020 13:31
-
-
Save mucahitkurt/7c4dda77d71e9363afb82871fdc9bf85 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class InvalidOrderStateToCancel: RuntimeException() | |
class Order(val orderSpecification: OrderSpecification) { | |
fun cancel() { | |
if (!orderSpecification.isCancellable(this)) { | |
throw InvalidOrderStateToCancel() | |
} | |
//…cancel order | |
} | |
fun isCancelled(): Boolean { | |
//…check order status | |
return true | |
} | |
} | |
class OrderSpecification { | |
fun isCancellable(order: Order): Boolean { | |
//…check order status | |
return true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment