Created
December 13, 2020 10:29
-
-
Save gahfy/cbb663fcada2b9425bb539558ad094c0 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 StateContext { | |
private var state: State? = null | |
fun setState(state: State?){ | |
this.state = state | |
} | |
public fun parseString(number: String): Boolean{ | |
setState(InitialState()) | |
for(character in number){ | |
parseCharacter(character) | |
} | |
return state?.final == true | |
} | |
private fun parseCharacter(character: Char){ | |
state?.parseCharacter(this, character) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment