Need help for Java Programming asap

Discussion in 'Programming' started by shabkhatereh, Apr 25, 2010.

  1. #1
    Hi everyone, I am looking for somone who can help me with JAVA Programming. I need this work by Tuesday 27th april, 5O'clock and I am sure this would be easy for you to help. please email me if you are interested in helping on : massi_jav@yahoo.com

    Here is the work: (Im writing it coz I wasn't able to attach it)

    Introduction
    In geometry, a straight line is the shortest distance between two points.
    A line may be characterised by its end points and its length.
    A line connects the points P1 and P2.

    The point P1 has coordinates {X1,Y1}.
    The point P2 has coordinates {X2,Y2}.
    The length of the line joining P1 and P2 is given by the equation:
    { (X2 - X1)2 + (Y2 - Y1)2 }1/2
    Those of you who are familiar with geometry will recognise the equation as being the well known Pythagoras equation for the hypotenuse of right angled triangles.

    Requirements
    Develop a class specification for the class Point.
    Write a short test program and test plan for this class.
    For example:
    //pointTest.java
    main(...)
    {
    Point P1;
    P1.create(24,16); // create a point with coordinates {24,16}
    P1.display(); // display the {X,Y} coordinates of P1
    .....
    }
    Develop a class specification for the class Line.
    Write a short test program and test plan for this class.
    For example:
    //lineTest.java
    main(...)
    {
    Point P1 = new Point();
    P1.create(24,16); // create a point with coordinates {24,16}
    Point P2 = new Point();
    P2.create(33,42); // create a point with coordinates {33,42}
    Line L1 = new Line();
    L1.create(P1,P2); // create a line using points P1 and P2
    System.out.println( L1.length() ); // display the length of line L1
    Line L2 = new Line();
    L2.create(12,30,28,16); // create a line using coordinates {12,30}, {28,16}
    L2.display(); // display the coordinates of both points and the length of the line
    .....
    }


    Application
    We wish to determine the length of the boundary of any regular or irregular polygon .
    The polygon may have up to 6 sides.
    The user should be prompted to enter the number of sides and the coordinates of each vertex point.
    The program should then calculate and display the total length of the boundary.
    You should write an application to implement this using your Point and Line classes.

    What I should have at the end
    The following:

    • A listing of the files Point.java, the class test program and results.
    • A listing of the files Line.java, the class test program and results.
    • The application program and results.
    Note 1: All code must be written in java.
     
    shabkhatereh, Apr 25, 2010 IP
  2. Amator

    Amator Well-Known Member

    Messages:
    1,424
    Likes Received:
    55
    Best Answers:
    0
    Trophy Points:
    165
    #2
    this sounds like shool work... by doing it yourself you learn the most
     
    Amator, Apr 25, 2010 IP
    sarahk likes this.
  3. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #3
    Looks like a pretty simple thing, create a Point class, that has two parameters, the X and Y with readonly int's with getters. Next create a Line class with two overloaded constructors, one that accepts two Point objects, one that is infite but throws errors if not given sets of two params (mod % 2 == 1). So in the point class its just a data object, holding the values. The line class's constructor for the points, just draws a line and pulls the x and y getters from the points. The other constructor iterates over all combinations (I advise creating a collection of points from this constructor) - then just calling the same draw but while iterating over the list instead of just doing one draw. I would personally create a factory that maps the types it could be to the drawing, plus an IPoint or IDrawable Interface but that might be out of scope for this homework assignment ;)
     
    ccoonen, Apr 25, 2010 IP
  4. extremephp

    extremephp Peon

    Messages:
    1,290
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    0
    #4
    DOing it in java Would be a great sort of work..!

    Do it in c++ and it could be easy for you buddy..!

    Or even i can help you out in it...!

    In c++ i can easily make a simple app to calculate the distance between 2 points where user can enter the Coordinates of the points.

    and you know making a polygon and finding its Boundary would make the whole stufs so diffficult..!
     
    extremephp, Apr 25, 2010 IP