-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPoint.cpp
More file actions
64 lines (52 loc) · 1.67 KB
/
Copy pathPoint.cpp
File metadata and controls
64 lines (52 loc) · 1.67 KB
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
/**************************************************************************************
**** Name: Austin Crow
**** Date: 2/27/19
**** Description: Source file for the class Point. This class will have get and set
**** functions for the x and y variables and will have a class function
**** that computes the distance between the current Point and another
**** Point paramater.
**************************************************************************************/
//Include class header
#include "Point.Hpp"
//Default constructor sets parameters to 0
Point::Point()
{
xPointCoord = 0;
yPointCoord = 0;
}
//Input parameters get assigned to Class variables
Point::Point(double xCoord, double yCoord)
{
xPointCoord = xCoord;
yPointCoord = yCoord;
}
//Get function for the x coordinate. returns a double
double Point::getXCoord()
{
return xPointCoord;
}
//Get function for the y coordinate. returns a double
double Point::getYCoord()
{
return yPointCoord;
}
//Set function for the x coordinate. accepts a double
void Point::setXCoord(double xCoord)
{
xPointCoord = xCoord;
}
//Set function for the y coordinate. accepts a double
void Point::setYcoord(double yCoord)
{
yPointCoord = yCoord;
}
//function to calculate distance to another Point class object.
//Accepts a Point class object, returns distance as a double.
double Point::distanceTo(Point fakePoint)
{
double distanceDouble = 0.0, xtotal = 0.0, ytotal = 0.0;
xtotal = pow(xPointCoord - fakePoint.getXCoord(),2);
ytotal = pow(yPointCoord - fakePoint.getYCoord(), 2);
distanceDouble = sqrt(xtotal + ytotal);
return distanceDouble;
}