• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java shape help  RSS feed

 
Tyler Walker
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need help to make my area and perimeter work for my ellipse shape, please help me.

Shape Interface:



Line Class:



Point Class:



Ellipse Class:



If you would like the Shape tester class, I will send it, but it has a lot of stuff that is not related to my question.
 
Carey Brown
Saloon Keeper
Posts: 3328
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've implemented those two methods, are they not giving you the correct results? If not, post your input and output and where you got the formulas from.

Minor nit. If you want to square N then don't use Math.pow(N,2) use N*N.
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Another nit to pick: is a line a shape? Is a point a shape? You are going to have to return 0 from the area/length methods.
Don't use Math#sqrt for Pythagoras. Find out about the Math#hypot method instead.
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Formatting problem:
Please have a look at this thread which explains why it is a bad idea to try and squash a whole method into one line.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!