Last active
August 15, 2018 23:18
-
-
Save fabio-filho/9658f9dabff41b4f9066dd3f07eb444b to your computer and use it in GitHub Desktop.
Contract and implementation
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
// 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