interface History { | |
fun push(url: URL) | |
fun pop(): URL | |
fun peek(): URL | |
} | |
class Browser( | |
private val history: History | |
) { | |
var activeURL: URL? = null | |
private set | |
fun visit(url: URL) { | |
activeURL = if (url == URL("http://default")) | |
history.peek() else | |
url | |
history.push(activeURL!!) | |
} | |
fun back() { | |
history.pop() | |
activeURL = history.peek() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment