#include "mypoint.h" #include #include int MyPoint_getX(myPt_t pt) { return pt->x; } int MyPoint_getY(myPt_t pt) { return pt->y; } void MyPoint_setX(myPt_t pt, int x) { pt->x = x; } void MyPoint_setY(myPt_t pt, int x) { pt->y = x; } double MyPoint_distance_to_origin1(myPt_t pt) { double x = (double)pt->x; double y = (double)pt->y; return sqrt(x * x + y * y); } double MyPoint_distance_to_origin2(myPt_t pt) { double x = (double)pt->getX(pt); double y = (double)pt->getY(pt); return sqrt(x * x + y * y); } myPt_t new_myPt(int x, int y) { myPt_t ans = (myPt_t)(malloc(sizeof(struct MyPoint))); ans->x = x; ans->y = y; ans->getX = MyPoint_getX; ans->getY = MyPoint_getY; ans->setX = MyPoint_setX; ans->setY = MyPoint_setY; ans->distance_to_origin1 = MyPoint_distance_to_origin1; ans->distance_to_origin2 = MyPoint_distance_to_origin2; return ans; }