使用C++完成二维点类小程序

题目描述:
要求编写一个类,来代表二维坐标系上的点
要求实现函数:
1.打印该点坐标
2.求两点之间距离
3.返回一个点对象,为该点相对于原点的(0,0)的对称点
4.判断点是否在给定圆内

输入格式:
第一行输入两个整数 x,y,代表点的坐标(x,y)
第二行输入一个整数case,代表测试数据的组数
对于每一组case,第一行输入一个数,代表要调用哪个函数,1 2 3 4对应题干函数
对于函数1,无后续输入
对于函数2,输入两个整数 p,q,代表另一个点的坐标(p,q)
对于函数3,无后续输入
对于函数4,输入两个整数p, q, r ,(p,q)代表圆心坐标,r代表圆的半径(d点在圆上不算做在圆内)

输出格式:
对于函数1,打印该点坐标,用空格隔开
对于函数2,打印两点间距离(误差不超过10^-5对于函数3,打印结果点坐标,用空格隔开
对于函数4,若点在圆内输出“Yes”,否则输出“No”

输入样例:
1 1
4
1
2
0 1
3
4
0 0 3

输出样例:
1 1
1
-1 -1
Yes

数据范围与提示:
输入的数均不超过1000

有用请采纳

#include<iostream>
#include<cmath>    // 使用sqrt 

using namespace std; 

class Point{
private:
    int x, y;

public:
    Point(double x, double y);
    void printPoint();
    void calculateDistance(double otherX, double otherY);
    Point symmetryPoint();
    void judgeInCircle(double p, double q, double r);
}; 

Point::Point(double x, double y){
    this->x = x;
    this->y = y;
}

void Point::printPoint(){
    cout << this->x << " " << this->y << endl; 
}

void Point::calculateDistance(double otherX, double otherY){
    double distance;
    distance = sqrt((otherX - this->x) * (otherX - this->x) + (otherY - this->y) * (otherY - this->y));
    
    printf("%.8lf\n", distance);
} 

Point Point::symmetryPoint(){
    cout << -this->x << " " << -this->y << endl;
}

void Point::judgeInCircle(double p, double q, double r){
    double distance; //圆心到点的距离
    distance =  sqrt((p - this->x) * (p - this->x) + (q - this->y) * (q - this->y));
    double judgeRange = 0.00001;

    if(fabs(distance) < r)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


int main(){
    double x, y;
    int choose, num;
    cin >> x >> y;
    Point point = Point(x, y);
    double otherX, otherY;
    double circleX, circleY, circleR;
    
    cin >> choose;
    for (int i = 0; i < choose; i++){
        cin >> num;
        switch(num){
            case 1: 
                point.printPoint(); 
                break;
            case 2: 
                cin >> otherX >> otherY;
                point.calculateDistance(otherX, otherY); 
                break;
            case 3: 
                point.symmetryPoint(); 
                break;
            case 4: 
                cin >> circleX >> circleY >> circleR;
                point.judgeInCircle(circleX, circleY, circleR);
                break;
            default:
                break;
        }
    }
}