d2jsp
Log InRegister
d2jsp Forums > Off-Topic > General Chat > Homework Help > Java Scripting Need Help > Java Need Help
Add Reply New Topic New Poll
Member
Posts: 2,204
Joined: Feb 4 2012
Gold: 1,645.05
Sep 18 2013 08:20pm
the question is Look at the API of the Point class and find out how many to construct a Point object. In a PointTester program, construct two points with coordinates (-3,-4). Find the distance between them, using distance method. Print the distance, as well as the expected value.


I've been trying for a bit now and still have nothing.
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Sep 18 2013 08:33pm
is this java or is this javascript? big difference.

and what is "expected value"? you mean the statistical term?

step 1. what is the constructor of the Point class?
step 2. how do you call the constructor above?
step 3. how do you find the distance between two points geometrically (non-coding)?
step 4. how do you use step 3 via code?
Member
Posts: 8,330
Joined: Jun 27 2005
Gold: 480.00
Sep 18 2013 09:44pm
I would guess there's a java API for the distance between 2 points already. Don't need to duplicate work.
Banned
Posts: 4,377
Joined: Dec 25 2012
Gold: 13,953.01
Warn: 10%
Sep 19 2013 01:43am
Quote (carteblanche @ Sep 18 2013 09:33pm)
is this java or is this javascript? big difference.

and what is "expected value"? you mean the statistical term?

step 1. what is the constructor of the Point class?
step 2. how do you call the constructor above?
step 3. how do you find the distance between two points geometrically (non-coding)?
step 4. how do you use step 3 via code?


He means java

I doubt that's what "expected value" means in this prompt, but who knows lol
Member
Posts: 2,204
Joined: Feb 4 2012
Gold: 1,645.05
Sep 19 2013 01:54am
i found this web site but im sick atm and need to go to bed (hence one of the reason's I cannot figure this out on my own) there will be a payment if you can figure it out while i take some meds and pass out (need by tomorrow 11 central time)
Member
Posts: 2,355
Joined: Apr 17 2009
Gold: 361.00
Sep 19 2013 04:52am
1.
The Point class has several constructors.

Point() gives a point at (0, 0)
Point(x, y) gives a point at (x, y)
Point (Point x) gives a point at the position of Point x.

2.

pointA = new Point(-3, -4);
pointB = new Point(-3, -4); // or pointB = new Point(PointA);

3.

System.out.println(pointA.distance(pointB));
System.out.println("Expected: 0 due to same location.");

For the full API, check the oracle docs you can find via google.

This post was edited by Onimo on Sep 19 2013 04:56am
Go Back To Homework Help Topic List
Add Reply New Topic New Poll