Skip to content

jotamusik/mouse-events-kata-kotlin

Repository files navigation

Mouse Events Kata

This kata is part of the book "Código sostenible".

Test-drive the methods missing the implementation:

class Mouse {
  private val listeners: MutableList<MouseEventListener> = mutableListOf()
  private val timeWindowInMillisecondsForDoubleClick: Long = 500
  fun pressLeftButton(currentTimeInMilliseconds: Long) {
    /*... implement this method ...*/
  }

  fun releaseLeftButton(currentTimeInMilliseconds: Long) {
    /*... implement this method ...*/
  }

  fun move(from: MousePointerCoordinates?, to: MousePointerCoordinates?, currentTimeInMilliseconds: Long) {
    /*... implement this method ...*/
  }

  fun subscribe(listener: MouseEventListener) {
    listeners.add(listener)
  }

  private fun notifySubscribers(eventType: MouseEventType) {
    listeners.forEach(Consumer<MouseEventListener> { listener: MouseEventListener ->
      listener.handleMouseEvent(
        eventType
      )
    })
  }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages