oop-exercises
oop-exercises copied to clipboard
create solution for the answer
when the create-exercise program is executed it creates a new exercise folder.. the script should add a new solution file to the answers folder
//SOL. FOR EXERCISE 1
#include <iostream>
#include <math.h>
using namespace std;
class Point {
private:
double x, y;
public:
const double GetX() { return x; }
const double GetY() { return y; }
void SetX(int X) { x = X; }
void SetY(int Y) { y = Y; }
//DISTANCE FUNCTION
double getDistance() {
return sqrt(pow(x, 2) + pow(y, 2));
}
//CONSTRUCTOR
Point(int x, int y){
this->x = x;
this->y = y;
}
};
int main() {
Point P(3, 4);
cout<<P.getDistance();
}
@luismonz would you please check https://github.com/kerolloz/oop-exercises/blob/master/answers/solution-1.cpp