File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Aggregating class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Aggregating class" Watch "Aggregating class" New topic

Aggregating class

brent bynum

Joined: Apr 04, 2012
Posts: 24
3. Create an aggregating class

Write a class called "Line". It should store two Point objects. It should have two
constructors, one that receives 4 ints to set the (x,y) of each end, and the other
that receives two Point objects.

It should have a distance method that computes the length of the line. Its toString
method should print like this: (x,y) to (x,y)

Write a main method that creates a line with each constructor. It should then print
each line and its length.


I am having the issue with the Point constructor and I am not sure where to go from here.

Any help is appreciated.
Steve Fahlbusch

Joined: Sep 18, 2000
Posts: 589

ok do you know the difference between integer math and floating point math?
Darryl Burke

Joined: May 03, 2008
Posts: 4756

brent bynum, please BeForthrightWhenCrossPostingToOtherSites

luck, db
There are no new questions, but there may be new answers.
surlac surlacovich
Ranch Hand

Joined: Mar 12, 2013
Posts: 296

brent bynum wrote:3. Create an aggregating class Write a class called "Line". It should store two Point objects.

Why Point must be aggregated by Line instead of composition, because Point can "live" without Line?
I agree. Here's the link:
subject: Aggregating class