Jeff Sak wrote:I feel like I have the correct algorithm to find the distance, but I am not able to get the output from it.
Several things:
1. Your distance() method appears to try to calculate the distance between two 2D points, but your Point class contains three coordinates.
2. You also cache the distance value when you calculate it, which doesn't make any sense since a point can't "have" a distance (except possibly from 0,0,0).
3. There's no point in caching it anyway, since you've made the class mutable  so you'd have to recalculate every time a coordinate changes.
4. double distance = Math.sqrt(PointX) * (PointX) + ... won't compile because you cant multiply (or add) Points.
HIH
Winston
"Leadership is nature's way of removing morons from the productive flow"  Dogbert
Articles by Winston can be found here
Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
 1
Winston Gutkowski wrote:4. double distance = Math.sqrt(PointX) * (PointX) + ... won't compile because you cant multiply (or add) Points.
Exactly! PointX is a double not a Point. Poor naming style.
Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
distance() is not a static method so you can't call it as Point.distance(...).
Your distance() takes two doubles and you are passing in two Point objects.
Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
Carey Brown wrote:Exactly! PointX is a double not a Point. Poor naming style.
Ooops. My mistake (well spotted).
However, it's still wrong because the only thing that will be √ed is the first argument.
@Jeff: My advice: Slow down, and think about what you're doing. If you don't know the formula for the distance between two points (two or threeD), look it up (or ask someone). And then think carefully about how you should fit it into your class ... before you write any code.
In general, your indenting and spacing is good, but try to stick to conventions  specifically: ALL method and variable names should start with a lower case letter.
HIH
Winston
"Leadership is nature's way of removing morons from the productive flow"  Dogbert
Articles by Winston can be found here
See where your hand is? Not there. It's next to this tiny ad:
The WEB SERVICES and JAXRS Course
https://coderanch.com/t/690789/WEBSERVICESJAXRS
