oop-exercises icon indicating copy to clipboard operation
oop-exercises copied to clipboard

create solution for the answer

Open kerolloz opened this issue 5 years ago • 2 comments

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

kerolloz avatar Apr 11 '19 00:04 kerolloz

//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 avatar Apr 13 '19 13:04 luismonz

@luismonz would you please check https://github.com/kerolloz/oop-exercises/blob/master/answers/solution-1.cpp

kerolloz avatar Apr 13 '19 15:04 kerolloz