-
Notifications
You must be signed in to change notification settings - Fork 0
/
point.hpp
62 lines (52 loc) · 961 Bytes
/
point.hpp
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// contains the definition of the class and its methods
#ifndef POINT_HPP
#define POINT_HPP
#include <iostream>
#include <vector>
#include <cmath>
#include <stdlib.h>
#include <string>
using namespace std;
class point
{
int x, y;
string name;
public:
point(int a, int b, string s)
{
x = a;
y = b;
name = s;
}
void setvalues(int a, int b, string s)
{
x = a;
y = b;
name = s;
}
void showPoint()
{
cout << name << " "
<< "(" << x << ',' << y << ")" << endl;
}
int getX()
{
return x;
}
int getY()
{
return y;
}
string getName(){
return name;
}
friend int distance_between_2Points(point p1, point p2);
};
int distance_between_2Points(point p1, point p2)
{
int x_diff = p1.x - p2.x;
int y_diff = p1.y - p2.y;
int hypo = hypot(x_diff, y_diff);
return hypo;
}
#endif