Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- #include <cmath>
- using namespace std;
- /*
- *
- * — Сколько тестировщиков нужно, чтобы поменять лампочку?
- * — Нисколько, они лишь указали, что в комнате темно.
- * Тестировщики не исправляют проблемы, они их находят.
- *
- */
- class PlanePoint {
- double x, y;
- public:
- PlanePoint(double x = 0, double y = 0) {
- this->x = x;
- this->y = y;
- };
- PlanePoint(const PlanePoint &a) {
- this->x = a.x;
- this->y = a.y;
- };
- PlanePoint random() {
- srand(time(0));
- return PlanePoint(rand() % 31 - 15, rand() % 31 - 15);
- };
- //Расстояние между двумя точками
- double distance(PlanePoint a) {
- return sqrt(pow(a.x - x, 2) + pow(a.y - y, 2));
- };
- bool equals(PlanePoint a) {
- if (a.rad() == this->rad())
- return true;
- return false;
- };
- bool operator==(PlanePoint a) {
- return this->equals(a);
- };
- bool operator!=(PlanePoint a) {
- return !(this->equals(a));
- };
- void operator=(PlanePoint b) {
- this->x = b.x;
- this->y = b.y;
- };
- friend ostream& operator<<(ostream& os, const PlanePoint& at) {
- os << "x=" << at.x << ", y=" << at.y;
- return os;
- };
- //Расстояние до центра
- double rad() {
- return sqrt(pow(x, 2) + pow(y, 2));
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment