It's not a secret anymore!
The moose likes Beginning Java and the fly likes class extension problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "class extension problem" Watch "class extension problem" New topic

class extension problem

MaryEllen Volb
Ranch Hand

Joined: Jan 31, 2001
Posts: 35
Yes, this is a class assignment, but I need SO much help in this class! Anyway, I have to write a subclass for triangle that extends GeometricObject. Class triangle is defined as follows:
public class Triangle extends GeometricObject
private double side1, side2, side3;
//Construct a Triangle with the specified sides
public Triangle(double side1, double side2, double side3);
//Implement the abstract method findArea in GeometriObject
public double findArea();
//Implement the abstract method findPerimeter in GeometricObject
public double findPerimeter();
I do have Heron's formula to find the area of a triangle, but I have no clue how to even begin to build this program.
PLEASE HELP!!! Thanks as always, Mary Ellen
Mark Savory
Ranch Hand

Joined: Feb 08, 2001
Posts: 122
Mary Ellen,
It looks like the class Triangle is already defined for you. All you have to do is code the body of the constructor, the 'findArea', and the 'findPerimeter' methods. You can also add a 'main' method to the Triangle class that creates a Triangle object and calls the methods that you created.
Junilu Lacar

Joined: Feb 26, 2001
Posts: 6529

Sorry MaryEllen, but I think that you owe it to yourself, your teacher, and your classmates to at least take a stab at solving this assignment on your own. If you get stuck, I'm sure that there will be many people here willing to nudge you in the right direction. But at least try to do it yourself first.

Junilu - [How to Ask Questions] [How to Answer Questions]
I agree. Here's the link:
subject: class extension problem
It's not a secret anymore!