@import("parsimonyLibrary/dynamicObjectExtDecl.mc")
|
|
|
|
#include <math.h>
|
|
|
|
@class struct Point { double x, y; };
|
|
|
|
@constructor("Point") oop newPoint(double x, double y)
|
|
{
|
|
self->x = x;
|
|
self->y = y;
|
|
}
|
|
|
|
@method("Point") double magnitude()
|
|
{
|
|
printf("point method : %f\n", sqrt(self->x * self->x * self->y * self->y));
|
|
return sqrt(self->x * self->x * self->y * self->y);
|
|
}
|
|
|
|
@method("Point") double getX()
|
|
{
|
|
printf("point method : %f\n", self->x);
|
|
return self->x;
|
|
}
|
|
|
|
int main()
|
|
{
|
|
oop p = newPoint(3, 4);
|
|
|
|
@send("p", "magnitude");
|
|
|
|
@send("p", "getX");
|
|
|
|
return 0;
|
|
}
|