diff --git a/src/main/scala/Mathematics/PythagoreanTheorem.scala b/src/main/scala/Mathematics/PythagoreanTheorem.scala new file mode 100644 index 0000000..40b1d98 --- /dev/null +++ b/src/main/scala/Mathematics/PythagoreanTheorem.scala @@ -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)) + } +} \ No newline at end of file diff --git a/src/test/scala/Mathematics/PythagoreanTheoremSpec.scala b/src/test/scala/Mathematics/PythagoreanTheoremSpec.scala new file mode 100644 index 0000000..395ddf8 --- /dev/null +++ b/src/test/scala/Mathematics/PythagoreanTheoremSpec.scala @@ -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) + } + +} \ No newline at end of file