Вы находитесь на странице: 1из 3

:

// , .
package geometry;
// Scanner .
import java.util.Scanner;
/* Main
* Point, . .
*
* , Point
* Main main. , Main
* Point.
*/
public class Main {
public static void main(String[] args) {
//
Point a = new Point();
System.out.println(" : ");
//
a.inputPoint();
//
// ,
// , .
Point b = new Point(0,0);
System.out.println(" : ");
//

b.inputPoint();
/* , ,
* .
* , a==b
* , a b () ,
*
* .
*/
if( a.isSame(b) ) {
System.out.println(" !");
} else {
System.out.println(" :
"+b.getDistance(a));
}
/*
* . .
*/
if( a.getRadius() < b.getRadius() ) {
System.out.println(" !");
} else if(a.getRadius() == b.getRadius()) {
System.out.println(" !");
} else {
System.out.println(" !");
}
}
}
class Point {
/* .

*
* .
* double.
*/
double x; //
double y; //
// : (x;y)
void printPoint() {
System.out.print("("+x+";"+y+")");
}
//
void setPoint(double a, double b) {
x = a;
y = b;
}
/* , ..
* , .
* .
* , ,
* I III .
*/
void setPoint(double a) {
x = a;
y = a;
}
//
void inputPoint() {
Scanner inp = new Scanner(System.in);
System.out.print(" : ");
double a = inp.nextDouble();
System.out.print(" : ");
double b = inp.nextDouble();
/* .
* .
*/
setPoint(a,b);
}
/* , .
* , , ,
* , ,
* _._
*/
boolean isSame(Point a) {
if(x == a.x && y == a.y) {
return true;
} else {
return false;
}
}
//
double getDistance(Point a) {
return Math.sqrt( Math.pow(x-a.x, 2) + Math.pow(y-a.y, 2) );
}
//
double getRadius() {
Point a = new Point(0,0);
return this.getDistance(a);

}
/* , ,
* ,
* , . int 0,
* double 0.0 .
*/
Point() {
x = 0;
y = 0;
}
/* ,
* , .
*/
Point(double x, double y) {
/* , ,
* , ,
* . , Java
* this, ,
* ,
* . , this.x
* ( ) .
*/
this.x = x;
this.y = y;
}
}

Вам также может понравиться