summaryrefslogtreecommitdiff
path: root/src/Q3
diff options
context:
space:
mode:
Diffstat (limited to 'src/Q3')
-rw-r--r--src/Q3/CartesianCoordinateSystem.java46
-rw-r--r--src/Q3/CartesianCoordinateSystemTest.java23
-rw-r--r--src/Q3/README.md101
3 files changed, 0 insertions, 170 deletions
diff --git a/src/Q3/CartesianCoordinateSystem.java b/src/Q3/CartesianCoordinateSystem.java
deleted file mode 100644
index abd7341..0000000
--- a/src/Q3/CartesianCoordinateSystem.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Assignment 1, COMP268 Class: CartesianCoordinateSystem.java
- *
- * @description Represents an object that can calculate the distance between two points on a
- * cartesian plain
- * @author: mo khan Student ID: 3431709
- * @date May 7, 2019
- * @version 1.0
- */
-package Q3;
-
-import java.util.Scanner;
-
-public class CartesianCoordinateSystem {
- /**
- * Calculate the distance between two points.
- *
- * @param x1 x coordinate for the first point.
- * @param y1 y coordinate for the first point.
- * @param x2 x coordinate for the second point.
- * @param y2 y coordinate for the second point.
- * @return the distance between the two points
- */
- 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;
- }
-
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
-
- System.out.print("Please enter X1: ");
- double x1 = in.nextDouble();
-
- System.out.print("Please enter Y1 contributions: ");
- double y1 = in.nextDouble();
-
- System.out.print("Please enter X2 contributions: ");
- double x2 = in.nextDouble();
-
- System.out.print("Please enter Y2 contributions: ");
- double y2 = in.nextDouble();
-
- CartesianCoordinateSystem cartesian = new CartesianCoordinateSystem();
- System.out.println("The distance is " + cartesian.calculateDistance(x1, y1, x2, y2));
- }
-}
diff --git a/src/Q3/CartesianCoordinateSystemTest.java b/src/Q3/CartesianCoordinateSystemTest.java
deleted file mode 100644
index 9906323..0000000
--- a/src/Q3/CartesianCoordinateSystemTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package ca.mokhan.test;
-
-import Q3.*;
-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));
- }
-}
diff --git a/src/Q3/README.md b/src/Q3/README.md
deleted file mode 100644
index 3edb62a..0000000
--- a/src/Q3/README.md
+++ /dev/null
@@ -1,101 +0,0 @@
-Learning Profile for Assignment #1, And Question #3
-
-Name: Mo Khan
-Student ID: 3431709
-
-1. Problem Statement:
-
-Write a program that prompts the user to enter two points `(x1, y1)` and `(x2, y2)`.
-Calculate and display the distance between the two points using the formula below.
-Round the answer up to 2 decimal points.
-You can use `Math.pow(a,0.5)` to compute the square root of an expression.
-`Math.pow()` returns a double.
-
-For example, the distance between the points (−2, −3) and (−4, 4) is approximately 7.28, as shown below.
-
-2. Description of the Code:
-
-[Briefly describe how you solved the problem in your code. You should include short description of classes, methods, and variables (if necessary) that you used in your code.]
-
-I took the example described in the problem statement and converted it
-to a junit test. Then I implemented the `calculateDistance` interface.
-
-3. Errors and Warnings:
-
-```bash
-モ mvn test
-[INFO] Scanning for projects...
-[INFO]
-[INFO] -------------------< ca.mokhan.comp268:assignment1 >--------------------
-[INFO] Building assignment1 1.0-SNAPSHOT
-[INFO] --------------------------------[ jar ]---------------------------------
-[INFO]
-[INFO] --- fmt-maven-plugin:2.8:format (default) @ assignment1 ---
-[INFO] Processed 48 files (0 reformatted).
-[INFO]
-[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ assignment1 ---
-[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
-[INFO] skip non existing resourceDirectory /Users/mokha/development/gh/comp-268/src/main/resources
-[INFO]
-[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ assignment1 ---
-[INFO] Changes detected - recompiling the module!
-[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
-[INFO] Compiling 24 source files to /Users/mokha/development/gh/comp-268/target/classes
-[INFO]
-[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ assignment1 ---
-[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
-[INFO] skip non existing resourceDirectory /Users/mokha/development/gh/comp-268/src/test/resources
-[INFO]
-[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ assignment1 ---
-[INFO] Changes detected - recompiling the module!
-[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
-[INFO] Compiling 24 source files to /Users/mokha/development/gh/comp-268/target/test-classes
-[INFO]
-[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ assignment1 ---
-[INFO] Surefire report directory: /Users/mokha/development/gh/comp-268/target/surefire-reports
-
--------------------------------------------------------
- T E S T S
--------------------------------------------------------
-Running ca.mokhan.comp268.AppTest
-Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.007 sec
-Running ca.mokhan.test.CandidateTest
-Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.046 sec
-Running ca.mokhan.test.NumberTest
-Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.021 sec
-Running ca.mokhan.test.EmployeeSavingsTest
-Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.007 sec
-Running ca.mokhan.test.CartesianCoordinateSystemTest
-Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec
-Running ca.mokhan.test.CommunicationTest
-Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec
-Running ca.mokhan.test.TaxReturnTest
-Tests run: 12, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec
-Running ca.mokhan.test.BanffMarathonRunnerTest
-Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec
-Running ca.mokhan.test.AddressBookTest
-Tests run: 12, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec
-Running ca.mokhan.test.TriangleTest
-Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec
-Running ca.mokhan.test.BonusOnSavingsTest
-Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec
-Running ca.mokhan.test.HailstoneSequenceTest
-Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec
-
-Results :
-
-Tests run: 52, Failures: 0, Errors: 0, Skipped: 0
-
-[INFO] ------------------------------------------------------------------------
-[INFO] BUILD SUCCESS
-[INFO] ------------------------------------------------------------------------
-[INFO] Total time: 2.899 s
-[INFO] Finished at: 2019-05-13T21:15:06-06:00
-[INFO] ------------------------------------------------------------------------
-```
-
-4. Sample Input and Output:
-
-Tests are available in `CartesianCoordinateSystemTest.java`.
-
-5. Discussion: