Google Answers Logo
View Question
 
Q: Java Triangle program (fairly basic) ( No Answer,   0 Comments )
Question  
Subject: Java Triangle program (fairly basic)
Category: Computers > Programming
Asked by: alex1977-ga
List Price: $30.00
Posted: 23 Nov 2006 13:33 PST
Expires: 24 Nov 2006 08:35 PST
Question ID: 785126
I have a computer science test on Monday which will have a very
similar question to the one below. If you could please have an answer
before Sunday, I would greatly appreciate it!! I am completely new to
java and want to see the code for this so that I can study and
understand it. The question is:

Create a Triangle class that implements all of the missing code from
the template below (fill in the missing code):

public class Triangle
{
private Coordinate a, b, c;

//default constructor: should generate random Coordinates
public Triangle();

//standard constructor
public Triangle(Coordinate newA, Coordinate newB, Coordinate newC);

//accessors
public Coordinate getVertexA();
public Coordinate getVertexB();
public Coordinate getVertexC();

public double getSideA();
public double getSideB();
public double getSideC();

public double getAngleA();
public double getAngleB();
public double getAngleC();

public boolean isValid();
public boolean isScalene();
public boolean isIsosceles();
public boolean isEquilateral();

public double getPerimeter();
public double getArea();

public String toString();
public boolean equals(Object o);

public boolean contains(Coordinate t);
public Circle getCircumcircle();
public Circle getIncircle();
}

That's all for the question.

Some auxiliary classes you may want to use to help you out:

public class Coordinate
{
//state variable(s)
private double x;
private double y;

//constructor function(s)
public Coordinate();
public Coordinate(double newX, double newY);
public Coordinate (Coordinate toBeCopied);

//accessor function(s)
public double getX();
public double getY();

//utility function(s)
public double distanceTo(Coordinate target)
{
double deltaX = x - target.getX();
double deltaY = y - target.getY();
double hypotSquared = (deltaX * deltaX) + (deltaY * deltaY);
return (Math.sqrt(hypotSquared));
}

public String toString()
{return ("(" + x + "," + y + ")")}
}

public class Circle
{
private Coordinate origin;
private double radius;

public Circle();
public Circle(Coordinate newOrigin, double newRadius);
}

Clarification of Question by alex1977-ga on 23 Nov 2006 13:40 PST
This is NOT an actual exam question, just one posed in a book for
solving that I tried to do and couldn't figure out. This answer is not
for credit in a course.

Request for Question Clarification by answerguru-ga on 23 Nov 2006 20:36 PST
Hi alex1977-ga,

You may want to reconsider your list price for the type of work you
are requesting. Remember that researchers receive 75% of the list
price.

Personally, I would be willing to answer this question for a $100 list price.

Thanks,
answerguru-ga

Clarification of Question by alex1977-ga on 24 Nov 2006 08:19 PST
In order to expedite the process, forget the code for the last three segments:

public boolean contains(Coordinate t);
public Circle getCircumcircle();
public Circle getIncircle();

Please answer soon! Time is incredibly important in this case!
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy