-
Notifications
You must be signed in to change notification settings - Fork 1
/
Point.h
74 lines (56 loc) · 2.29 KB
/
Point.h
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
63
64
65
66
67
68
69
70
71
72
73
74
//******************************************************************************
// Point.h
// Inheritance
//
// Created by Karlina Beringer on July 8, 2014.
//
// This header file contains the Point class declaration.
// Point is included in Quadrilateral through composition.
//******************************************************************************
#ifndef Point_h
#define Point_h
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
//------------------------------------------------------------------
// Point represents a coordinate pair on a two-dimensional plane.
//------------------------------------------------------------------
class Point
{
private:
// X and Y coordinates describe a point on a plane.
double X_coordinate, Y_coordinate;
public:
// Default constructor creates a Point at the graph origin.
Point();
// Normal constructor creates a custom Point object.
Point( double X, double Y );
// Copy constructor creates a clone of a Point object.
Point( Point & point );
// Setter changes the value of the X_coordinate.
void setX( double X );
// Setter changes the value of the Y_coordinate.
void setY( double Y );
// Getter returns the value of the X_coordinate.
double getX();
// Getter returns the value of the Y_coordinate.
double getY();
// Getter computes the distance between this and another Point.
// Distance = Square_Root[ ((X2 - X1)^2) + ((X2 - X1)^2) ]
double getDistance( Point & point );
// Getter computes the slope between this and another Point.
// Slope = (Y2 - Y1) / (X2 - X1)
double getSlope( Point & point );
// Getter prints the coordinate pair of Point in the form ( X, Y ).
// If no ostream parameter is supplied, default will be cout.
void print( ostream & output = cout );
// Friend function behaves like Points's print method.
// Overloads the ostream operator.
// Friend is NOT a member of Point, but has access to its members.
friend ostream & operator << ( ostream & output, Point & point );
};
#endif
//******************************************************************************
// End of File
//******************************************************************************