-
Beginner Question: Class Capabilities
Hello All,
I missed a few lectures in class and I got very behind. My assignment is to:
Create a base class named "Rectangle" that contains length and width data members. From this class, derive a class named "Box" having an additional data memner named "depth". The method members of the base "Rectangle" class should consist of a constructor and an override method named "area()" method. The derived "Box" class should have a constructor and an override method named "area()" that retuns the surface area od the box and a "volume()" method.
Include in the classes constructed for the previous exercise in a working Java program. Have yoru program call all of the member methods in each class and explain the result when the area method is called using the two "box" objects.
Can someone guide me in the right direction? Can you show me how to set up the first part? I am very thankful for any help I get.
Evan
-
Parent class is Rectangle, fields length and width, method area. Child class is Box with fields length and width (inherited from parent) and depth, methods area (inherited but overridden) and volume. Your Box class will have to construct its Rectangle-ness before itself. I trust you know how to calculate areas and volume.
Is this a "Shape" hierarchy? Are these derived from "Shape"? if so, you'll need to initialize their "Shapeness", too.
Similar Threads
-
By Shailesh C.Rathod in forum .NET
Replies: 2
Last Post: 03-13-2002, 07:53 PM
-
By Patrick Ireland in forum .NET
Replies: 5
Last Post: 05-10-2001, 06:19 PM
-
By Patrick Ireland in forum .NET
Replies: 3
Last Post: 05-07-2001, 03:04 PM
-
By Gary McCallum in forum Java
Replies: 2
Last Post: 10-20-2000, 11:20 AM
-
Replies: 1
Last Post: 09-06-2000, 01:13 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks