Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

class extension problem

 
MaryEllen Volb
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
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
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Pie
Posts: 7465
50
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
J.Lacar
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic