diff options
| author | mokha <mokha@cisco.com> | 2019-05-05 19:48:09 -0600 |
|---|---|---|
| committer | mokha <mokha@cisco.com> | 2019-05-05 19:48:09 -0600 |
| commit | 99a28d2dba93642e89a62ecf905a3bd4f138318d (patch) | |
| tree | ee10a7df683642a42991896bbec5ced501a2abd1 /src/section-3 | |
| parent | 3c2be35d16d7482442911f5b06b68512f86e15b5 (diff) | |
split code into directories closer to what the instructor wants
Diffstat (limited to 'src/section-3')
| -rw-r--r-- | src/section-3/CartesianCoordinateSystem.java | 7 | ||||
| -rw-r--r-- | src/section-3/CartesianCoordinateSystemTest.java | 22 |
2 files changed, 29 insertions, 0 deletions
diff --git a/src/section-3/CartesianCoordinateSystem.java b/src/section-3/CartesianCoordinateSystem.java new file mode 100644 index 0000000..d6681f9 --- /dev/null +++ b/src/section-3/CartesianCoordinateSystem.java @@ -0,0 +1,7 @@ +package ca.mokhan.assignment1; + +public class CartesianCoordinateSystem { + public double calculateDistance(double x1, double y1, double x2, double y2) { + return Math.round(Math.pow(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2), 0.5) * 100) / 100.0; + } +} diff --git a/src/section-3/CartesianCoordinateSystemTest.java b/src/section-3/CartesianCoordinateSystemTest.java new file mode 100644 index 0000000..6696ce1 --- /dev/null +++ b/src/section-3/CartesianCoordinateSystemTest.java @@ -0,0 +1,22 @@ +package ca.mokhan.assignment1; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +public class CartesianCoordinateSystemTest extends TestCase { + private CartesianCoordinateSystem subject; + + public CartesianCoordinateSystemTest(String testName) { + super(testName); + this.subject = new CartesianCoordinateSystem(); + } + + public static Test suite() { + return new TestSuite(CartesianCoordinateSystemTest.class); + } + + public void testDistanceBetweenPoints() { + assertEquals(7.28, subject.calculateDistance(-2, -3, -4, 4)); + } +} |
