triangle, rectangle and TwoDShape

Thread Solved

Join Date: Apr 2007
Posts: 126
Reputation: new_2_java is an unknown quantity at this point 
Solved Threads: 6
new_2_java new_2_java is offline Offline
Junior Poster

Re: triangle, rectangle and TwoDShape

 
1
  #11
Feb 28th, 2008
Originally Posted by piers View Post
I changed it in my rectangle class but I am still getting 0.0 when I run my driver class.

Do you ever call the calculateAre of Triangle and Rectangle? you should call calculateArea to actually calculate and assing new value to area e.g.
  1. class TwoDShapeDriver
  2. {
  3. public static void main (String []args)
  4. {
  5. Triangle t1 = new Triangle(44,55,"scalene");
  6. t1.calculateArea();
  7. System.out.println(t1.toString());
  8.  
  9.  
  10. Rectangle r1 = new Rectangle(22,44);
  11. r1.calculateArea();
  12. System.out.println(r1.toString());
  13. }
  14. }
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 57
Reputation: piers is an unknown quantity at this point 
Solved Threads: 2
piers piers is offline Offline
Junior Poster in Training

Re: triangle, rectangle and TwoDShape

 
0
  #12
Feb 28th, 2008
thnx m8. I have solved it. Your spot on. I wasnt using my methods properly. once I have handed the homework in I will post my solution if ur interested. Until then this is a solved thread and I think if I am able 2 u can have a rep point for your help.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC