-
Notifications
You must be signed in to change notification settings - Fork 0
/
Wall.h
125 lines (118 loc) · 4.32 KB
/
Wall.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#ifndef WALL_H
#define WALL_H
#include "Particle.h"
#include "Exception.h"
class CurvyWall;
class Wall {
friend class CurvyWall;
protected:
float length;
Particle start;
Particle end;
virtual bool whoami() const {return true;}
public: // Do NOT make any modifications below!
/*********************************************************************
* Constructor
*
* @param is the length of the Wall
*/
Wall(float);
/*********************************************************************
* Constructor
*
* The first @param is the start point of Wall
* The second @param is the end point of Wall
* The Wall object is defined in counterclockwise direction.
*/
Wall(const Particle&, const Particle&);
/*********************************************************************
* Copy constructor
*
* Deep copy
*/
Wall(const Wall&);
/*********************************************************************
* GetInitialParticle
*
* @return the start point of Wall
* This method will be called only for the walls construted with their start
and end points
*/
const Particle& GetInitialParticle() const;
/*********************************************************************
* GetFinalParticle
*
* @return the end point of Wall
* This method will be called only for the walls construted with their start
and end points
*/
const Particle& GetFinalParticle() const;
/*********************************************************************
* FindAngleBetween
*
* @return the angle between this Wall object and the one given in the @param
*/
float FindAngleBetween(const Wall&) const;
/*********************************************************************
* GetLength
*
* @return the length of Wall
*/
float GetLength() const;
/*********************************************************************
* ComputeLength
*
* Computes the length of the Wall object
*/
virtual void ComputeLength();
/*********************************************************************
* Clone
*
* @return pointer to a copy of this Wall object
*/
virtual Wall* Clone() const;
/*********************************************************************
* IsContinuousLinear
*
* Checks whether the end points of this Wall object and the end points
of the Wall given in the @param are linear and the walls are continuous
* @return true if they are linear and continuous, false otherwise
* The method returns always false in case that the wall given in the
argument is a curvy wall
* Two walls are linear only if they are straight walls and their slopes
are equal (Be cautious while calculating slope of the vertical lines!)
* Two walls are continuous only if one starts at the point where the
other ends (the fact that which one of the two walls starts first is
not important.)
* The walls to be combined will always be the ones constructed with
their start and end points (anomalous examples will not be tested.)
*/
virtual bool IsContinuousLinear(const Wall&) const;
/*********************************************************************
* Operator overload
*
* Combines this Wall object with the Wall given in the @param
* @return the combined wall
* Two walls can be combined only if one of the two cases below are
satisfied:
- They are both straight walls such that one starts at the point
where the other ends
- They are both curvy walls such that one starts at the point where
the other ends and their center is common (coordinates of their
center points are the same)
- On the other hand, the fact that which one of the two walls starts
first is not important. Similar to the fact that 3+5 = 5+3.
* For the cases which do not satisfy above, the method should throw
ApplePearException which was defined in Exception.h.
* The walls to be combined will always be the ones constructed with
their start and end points (anomalous examples will not be tested.)
*/
virtual const Wall& operator+(const Wall&) const;
/*********************************************************************
* Destructor
*
*/
virtual ~Wall();
/********************************************************************/
};
#endif