aspose file tools*
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
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: 556

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

Joined: May 03, 2008
Posts: 4523

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?
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Aggregating class
Similar Threads
flicker in my program
error: invalid method declaration; return type required?
Drawing a Diamond Shape (like Rectangle, Circle)
Calculating the distance between two points problem