Skip to content

Instantly share code, notes, and snippets.

@fabio-filho
Last active August 15, 2018 23:18
Show Gist options
  • Save fabio-filho/9658f9dabff41b4f9066dd3f07eb444b to your computer and use it in GitHub Desktop.
Save fabio-filho/9658f9dabff41b4f9066dd3f07eb444b to your computer and use it in GitHub Desktop.
Contract and implementation
// Contract
interface INormalize{
fun order()
fun normalize()
fun getScore()
}
// Base class
abstract class Normalize : INormalize{
override fun order() {
}
override fun getScore() {
}
}
// Implementation class
class AdNormalize : Normalize(){
override fun normalize() {
normalizeEntry()
}
private fun normalizeEntry(){
System.out.print("entry")
}
}
// Implementation class
class KeywordNormalize : Normalize(){
override fun normalize() {
normalizeBig()
}
private fun normalizeBig(){
System.out.print("big")
}
}
fun main(){
val normalize : INormalize
normalize = KeywordNormalize()
normalize.normalize()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment