-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPoint.cpp
More file actions
47 lines (39 loc) · 750 Bytes
/
Point.cpp
File metadata and controls
47 lines (39 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include"Point.h"
#include<iostream>
using namespace std;
Point::Point() //Constructor sets values of x and y to 0
{
x = 0;
y = 0;
}
Point::Point(int num1, int num2) //x and y values change according to num1 and num2
{
x = num1;
y = num2;
}
void Point:: setX(int a) //set value of x to a
{
x = a;
}
void Point::setY(int b) //set value of y to b
{
y = b;
}
const int Point::getX() //return new x
{
return x;
}
const int Point::getY() //return new y
{
return y;
}
void Point::displayXY() //cout x and y
{
cout << "X = " << x << endl;
cout << "Y = " << y << endl;
}
const double Point::distance(Point point2) //distance betweem 2 points
{
double distance = sqrt(pow(x - point2.x, 2) + pow(y - point2.y, 2));
return distance;
}