Results 1 to 7 of 7
  1. #1
    DPdieciocho is offline Member
    Join Date
    Jun 2013
    Location
    Philippines
    Posts
    15
    Rep Power
    0

    Default MyTriangle Class

    I need to create a class called MyTriangle, which models a triangle with 3 vertices, is designed as follows. The MyTriangle class uses three MyPoint instances as the three vertices.

    The class contains:

    -Three private instance variables v1, v2, v3 (instances of MyPoint), for the three vertices.
    -A constructor that constructs a MyTriangle with three points v1=(x1, y1), v2=(x2, y2), v3=(x3, y3).
    -An overloaded constructor that constructs a MyTriangle given three instances of MyPoint.
    -A toString() method that returns a string description of the instance in the format "Triangle @ (x1, y1), (x2, y2), (x3, y3)".
    -A getPerimeter() method that returns the length of the perimeter in double. You should use the distance() method of MyPoint to compute the perimeter.
    -A method printType(), which prints "equilateral" if all the three sides are equal, "isosceles" if any two of the three sides are equal, or "scalene" if the three sides are different.

    Write the MyTriangle class. Also write a test program (called TestMyTriangle) to test all the methods defined in the class.


    PS: The class MyPoint is attached.
    Attached Files Attached Files

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,618
    Rep Power
    5

    Default Re: MyTriangle Class

    Is there a question here?

    Please go through these pages - they try again.
    Guide For New Members
    BB Code List - Java Programming Forum - Learn Java Programming



    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  3. #3
    allaudin's Avatar
    allaudin is offline Senior Member
    Join Date
    Apr 2013
    Posts
    271
    Rep Power
    0

    Default Re: MyTriangle Class

    Whats wrong with this class now ???

  4. #4
    DPdieciocho is offline Member
    Join Date
    Jun 2013
    Location
    Philippines
    Posts
    15
    Rep Power
    0

    Default Re: MyTriangle Class

    I'm going to create another class which is the TestMyTriangle to test if the MyTriangle class works. But then, I don't know how to get the vertices of each point which is the x1, x2, x3, y1, y2, y3.

  5. #5
    allaudin's Avatar
    allaudin is offline Senior Member
    Join Date
    Apr 2013
    Posts
    271
    Rep Power
    0

    Default Re: MyTriangle Class

    Taking Input from User in Java
    For more information, read API documentation of Scanner Class
    Last edited by allaudin; 08-25-2013 at 05:39 PM.

  6. #6
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default Re: MyTriangle Class

    Quote Originally Posted by DPdieciocho View Post
    I'm going to create another class which is the TestMyTriangle to test if the MyTriangle class works. But then, I don't know how to get the vertices of each point which is the x1, x2, x3, y1, y2, y3.
    You will need to provide these values. You can either hard code them in your test class or get them via user input.

  7. #7
    DPdieciocho is offline Member
    Join Date
    Jun 2013
    Location
    Philippines
    Posts
    15
    Rep Power
    0

Similar Threads

  1. Replies: 1
    Last Post: 12-13-2012, 03:06 AM
  2. Replies: 1
    Last Post: 11-29-2012, 09:46 AM
  3. Replies: 0
    Last Post: 12-07-2011, 11:55 AM
  4. Replies: 0
    Last Post: 03-27-2011, 05:49 AM
  5. Replies: 5
    Last Post: 01-26-2011, 06:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •