-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLine.cpp
More file actions
65 lines (63 loc) · 1.4 KB
/
Line.cpp
File metadata and controls
65 lines (63 loc) · 1.4 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
57
58
59
60
61
62
63
64
65
#include "Line.h"
Line::Line(double startX, double startY, double endX, double endY, const char* color, unsigned int ID) : Shapes(startX, startY, color, ID)
{
this->end.SetX(endX);
this->end.SetY(endY);
}
Point Line::GetEnd()
{
return end;
}
void Line::Print(ostream& strm)
{
strm << " <line ";
start.Print(strm);
end.Print(strm);
strm << "fill=" << '"' << color << '"' << " " << "/>";
strm << endl;
}
void Line::Print()
{
cout << ID << ". line, ";
start.Print();
cout << ", ";
end.Print();
cout << ", ";
cout << color;
cout << endl;
}
void Line::Translate(double vertical, double horizontal)
{
start.SetX(start.GetX() + horizontal);
start.SetY(start.GetY() + horizontal);
end.SetX(end.GetX() + horizontal);
end.SetY(end.GetY() + horizontal);
}
bool Line::WithinRectangle(double startX, double startY, double width, double height)
{
if (start.WithinRectangle(startX, startY, width, height) && end.WithinRectangle(startX, startY, width, height))
{
this->Print(cout);
return true;
}
else
return false;
}
bool Line::WithinCircle(double startX, double startY, double radius)
{
if (start.WithinCircle(startX, startY, radius) && end.WithinCircle(startX, startY, radius))
{
this->Print(cout);
return true;
}
else
return false;
}
double Area(double width, double height)
{
return 0;
}
Shapes* Line::clone()
{
return new Line(*this);
}