-
Notifications
You must be signed in to change notification settings - Fork 41
add Tests #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
add Tests #32
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,23 @@ | ||
| const Line = require('./ecs6-class/line') | ||
| const Point = require('./ecs6-class/point') | ||
|
|
||
| const calculateDistance = (point1, point2) => { | ||
| if (!point1 || !point2) { | ||
| throw new Error('missing data') | ||
| } | ||
| if (!(point1 instanceof Point) || !(point2 instanceof Point)) { | ||
| throw new Error('argument must by type point') | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which one is not a point? |
||
| } | ||
| let distanceX = (point2.x - point1.x) ** 2; | ||
| let distanceY = (point2.y - point2.y) ** 2; | ||
| let distanceY = (point2.y - point1.y) ** 2; | ||
| const distance = Math.sqrt(distanceX + distanceY); | ||
| return distance; | ||
| } | ||
|
|
||
| const calculateJunctionPoint = (line1, line2) => { | ||
| if (line1 == undefined || line2 == undefined) { | ||
| throw new Error("missing data") | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. which one is undefined |
||
| } | ||
| if (line1.slope === line2.slope) { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Who said that the slope is already calculated? (from both arguments) |
||
| if (line1.n === line2.n) { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Who said the the n is already calculated? |
||
| return true | ||
|
|
@@ -24,6 +34,9 @@ const calculateJunctionPoint = (line1, line2) => { | |
| } | ||
|
|
||
| const isPointOnLine = (line, point) => { | ||
| if (!line || !line.slope || !line.n || !point) { | ||
| throw new Error("missing data") | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. write tests that line = {slope:6, n:1} and point:56
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check the basics and then you can calculate the missing data |
||
| } | ||
| const proxyLine = new Line({ point1: line.point1, point2: point }) | ||
| proxyLine.calculateSlope() | ||
| if (line.slope === proxyLine.slope) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.