This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Aggregating class

 
brent bynum
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.





Output:



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
Bartender
Posts: 605
7
Mac OS X Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok do you know the difference between integer math and floating point math?
 
Darryl Burke
Bartender
Posts: 5126
11
Java Netbeans IDE Opera
 
surlac surlacovich
Ranch Hand
Posts: 296
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic