/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <iostream>
#include "tpunkt.h"
using namespace std;
int main()
{
TPunkt p1(1,1), p2(0,3), p3;
cout << p1.getX() << endl;
cout << p2.getY() << endl;
// cout<<p3.Odleglosc(p1,p2);
return 0;
}
#ifndef TPUNKT_H
#define TPUNKT_H
class TPunkt
{
public:
TPunkt ();
TPunkt(float ,float );
float getX();
float getY();
void setX(float x);
void setY(float y);
void Odleglosc(const TPunkt &b);
float Odleglosc(const TPunkt &b) const;
protected:
float x;
float y;
};
#endif
#include "tpunkt.h"
TPunkt::TPunkt()
{
x=0;
y=0;
}
TPunkt::TPunkt(float x,float y)
{
this->x = x;
this->y = y;
}
float TPunkt::getX()
{
return x;
}
float TPunkt::getY()
{
return y;
}
void TPunkt::setX(float x)
{
this->x = x;
}
void TPunkt::setY(float y)
{
this->y = y;
}
void TPunkt::Odleglosc(const TPunkt &b)
{
x = b.x;
y = b.y;
}
float TPunkt::Odleglosc(const TPunkt &b) const
{
return hypot(this->x - b.x, this->y - b.y);
}