Write a program to calculate the midpoint of two 2D coordinate points. A) Among them, the Point class represents two-dimensional coordinate points and has private member variables x and y, representing the values of the abscissa and ordinate, initialized by the constructor. B) Four methods setX (), getX (), setY (), and getY () are used to set and obtain the coordinates. In addition, a member method midPoint (Point p), which takes a Point object as a parameter, calculates the midpoint of the two coordinates and returns a new two-dimensional point. It is required to reflect the encapsulation characteristics in the program. Instantiate two two-dimensional points (4, 5) and (6, 8) in the main function of the class Test. Calculate the midpoint of the two by calling the midPoint of one of them and return a new two-dimensional point, and outputs the x and y of the new point.
Subject: Java
Hi Expert Sir,
this (A, B) is one question...... please read and solve it carefully. and Don't submit the wrong answer. It's very important to me.... thank you
Write a program to calculate the midpoint of two 2D coordinate points.
A) Among them, the Point class represents two-dimensional coordinate points and has private member variables x and y, representing the values of the abscissa and ordinate, initialized by the constructor.
B) Four methods setX (), getX (), setY (), and getY () are used to set and obtain the coordinates. In addition, a member method midPoint (Point p), which takes a Point object as a parameter, calculates the midpoint of the two coordinates and returns a new two-dimensional point.
It is required to reflect the encapsulation characteristics in the program. Instantiate two two-dimensional points (4, 5) and (6, 8) in the main function of the class Test. Calculate the midpoint of the two by calling the midPoint of one of them and return a new two-dimensional point, and outputs the x and y of the new point.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 4 images