-->
当前位置:首页 > 题库

PROGRAMMING:spot

Luz5年前 (2021-05-10)题库573
Point is the simplest shape and the most basic part of geometry. It is required to design a point class, which includes: < br / >

  1. Coordinate member variables int x, int y

  2. The setter gette method and toString method of member variables X and y

  3. Parametric nonparametric construction method

  4. Override the hashcode and equals methods to determine whether the two points are the same

  5. Implement the interface comparable to compare the size of two points. The comparison rule is that if the first point x is large, the first point is large, and if the first point x is small, the first point is small. If it is the same, compare y and judge the size according to the value of Y
  6. Implementation method int distance (point P2), find the distance between two points (square root method math. Sqrt())


In the main method of the test class, the requirements are as follows: < br / > < ol >
  • Input two point coordinates through the keyboard, create two point objects < / Li > < li > output the information of the first point (call toString method), < / Li > < li > compare their sizes, if the first point is greater than or equal to the second point, output true, otherwise output false < / Li > < li > calculate the distance between the two points and output

    ###Input format:
    Please write the input format here. For example: input 2 integers a and B with absolute value no more than 1000 in one line.
    ###Output format:
    Enter two lines, one for each line
    ###Input example:
    Here is a set of inputs. For example:
    ```in
    4 6
    6 7
    ```
    ```in
    4 5
    3 2
    ```
    ###Output example:
    The corresponding output is given here. For example:
    ```out
    Point [x=4, y=6]
    false
    two
    ```
    ```out
    Point [x=4, y=5]
    true
    three
    ```






    answer:If there is no answer, please comment