Results 21 to 29 of 29
Thread: Help with multiple classes
- 11-27-2011, 09:44 PM #21
Member
- Join Date
- Sep 2011
- Posts
- 45
- Rep Power
- 0
Re: Help with multiple classes
Are you talking about this block of code from the tester
??Java Code:for (int radius = 1; radius < 5; ++radius) for (int height = 1; height < 5; ++height) { if (radius == height) spheres.add(new Sphere(radius)); if (radius > height) cones.add(new Cone(radius, height)); if (radius + height == 6) cylinders.add(new Cylinder(radius, height)); }
I would assume the data there is well, from the for loop...Yes?
Aside from radius and height I don't think it needs anything else =/
- 11-27-2011, 09:49 PM #22
Re: Help with multiple classes
Look at only the code for the Sphere class!!!
What data is in an instance of an object. If you create a Sphere object, what data does it have it in?
Does it need anything more to compute its volume?
When you create an instance of the Sphere class, what data is given to the constructor?
- 11-27-2011, 09:51 PM #23
Member
- Join Date
- Sep 2011
- Posts
- 45
- Rep Power
- 0
Re: Help with multiple classes
Sorry, my mind is sort of shutting down...too much programming and calculus. Let me think about that for a while and get back to you.
- 11-27-2011, 10:39 PM #24
Member
- Join Date
- Sep 2011
- Posts
- 45
- Rep Power
- 0
Re: Help with multiple classes
Okay, by data are you talking about my private radius variable that was initialized to 0? If not, I do not know what you mean.
- 11-27-2011, 10:42 PM #25
Re: Help with multiple classes
What more do you need than the radius to compute the volume?
Does the Sphere class object get its radius when it is created?
- 11-27-2011, 10:46 PM #26
Member
- Join Date
- Sep 2011
- Posts
- 45
- Rep Power
- 0
Re: Help with multiple classes
Nothing. A radius of type double is the only parameter in the getVolume method.
And I am not sure if it got its radius when created...should I still be looking in the sphere class, or the test class now?
- 11-27-2011, 10:52 PM #27
Re: Help with multiple classes
Your problem was in creating and using the getVolume() method.
Does it need any parameters or does the Sphere object contain all the data needed to compute the volume?
- 11-27-2011, 11:00 PM #28
Member
- Join Date
- Sep 2011
- Posts
- 45
- Rep Power
- 0
Re: Help with multiple classes
..........(moment of enlightenment)
I understand now...I should not have put in parameters for getVolume or getSurfaceArea. I think my program works now, if I have any issues I'll be posting them on this thread. Thanks for all your time and patience helping me understand this!
- 11-27-2011, 11:01 PM #29
Similar Threads
-
Multiple classes error
By nat45928 in forum New To JavaReplies: 0Last Post: 05-09-2011, 02:10 AM -
Multiple images from different classes
By superbriggs in forum Java 2DReplies: 1Last Post: 03-20-2011, 08:59 AM -
Multiple classes
By Lund01 in forum New To JavaReplies: 1Last Post: 03-16-2011, 02:58 PM -
help with GUI and multiple classes
By sssss in forum Advanced JavaReplies: 14Last Post: 01-16-2011, 10:08 PM -
Help with multiple frames/classes
By Celletti in forum AWT / SwingReplies: 1Last Post: 04-28-2010, 03:18 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks