-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathRectangle.cpp
More file actions
41 lines (34 loc) · 725 Bytes
/
Rectangle.cpp
File metadata and controls
41 lines (34 loc) · 725 Bytes
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
#include "Rectangle.hpp"
#include <iostream>
Rectangle::Rectangle(double x, double y)
: x_(x),
y_(y)
{}
Rectangle::Rectangle(const Rectangle &other)
{
x_ = other.getX();
y_ = other.getY();
}
double Rectangle::getArea() const
{
return x_ * y_;
}
double Rectangle::getPerimeter() const
{
return 2 * (x_ + y_);
}
double Rectangle::getX() const
{
return x_;
}
double Rectangle::getY() const
{
return y_;
}
void Rectangle::print() const
{
std::cout << "Rectangle: x: " << getX() << std::endl
<< " y: " << getY() << std::endl
<< " area: " << getArea() << std::endl
<< " perimeter: " << getPerimeter() << std::endl;
}