feat(ex03): it works
This commit is contained in:
parent
6f17e2e888
commit
b4f48cdfb0
8 changed files with 322 additions and 0 deletions
24
ex03/Point.cpp
Normal file
24
ex03/Point.cpp
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#include "Point.hpp"
|
||||
#include <iostream>
|
||||
|
||||
Point::Point() : x(0), y(0) {}
|
||||
Point::Point(float x, float y) : x(Fixed(x)), y(Fixed(y)) {}
|
||||
Point::Point(Point const &other) : x(other.x), y(other.y) {}
|
||||
Point &Point::operator=(const Point &other) {
|
||||
(void)other;
|
||||
std::cerr << "WARNING: called Point::operator=, which is a noop due to x and "
|
||||
"y being const."
|
||||
<< std::endl;
|
||||
return *this;
|
||||
};
|
||||
Point::~Point() {}
|
||||
|
||||
Fixed Point::triangleArea(Point const &a, Point const &b, Point const &c) {
|
||||
return (((a.x * (b.y - c.y)) + (b.x * (c.y - a.y)) + (c.x * (a.y - b.y))) / 2)
|
||||
.abs();
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &stream, const Point &p) {
|
||||
stream << "(" << p.x << ", " << p.y << ")";
|
||||
return stream;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue