Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/main/scala/Mathematics/PythagoreanTheorem.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package Mathematics

object PythagoreanTheorem {

/** Returns two dimension distant */
def distance(x: Double, y: Double): Double = {
Math.sqrt(Math.pow(x,2) + Math.pow(y,2))
}
}
11 changes: 11 additions & 0 deletions src/test/scala/Mathematics/PythagoreanTheoremSpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package Mathematics

import org.scalatest.flatspec.AnyFlatSpec

class PythagoreanTheoremSpec extends AnyFlatSpec {

"Pythagorean Theorem 1" should "output the correct distant" in {
assert(PythagoreanTheorem.distance(3,4) === 5)
}

}