@(import("class.mc"))
|
|
|
|
@{
|
|
//creation of the class
|
|
P = initClass();
|
|
P.values.x = "null";
|
|
P.values.y = "null";
|
|
P.values.z = "null";
|
|
P.functions.printf = "null";
|
|
printf(p) { // Can we create a self variable or somthing like that ?
|
|
print("Object P : ");
|
|
print(p);
|
|
print("\n");
|
|
}
|
|
P.functions.printf = printf;
|
|
|
|
// To know if the parameter is known
|
|
print("\n");
|
|
(P.values.x != null) ? print("yes\n") : print("no\n");
|
|
(P.values.w != null) ? print("yes\n") : print("no\n");
|
|
print("\n");
|
|
|
|
// Use of the P class
|
|
x = new(P, {x: 2, y: 4, z: 6, w: 9});
|
|
x.functions.printf(x);
|
|
|
|
// Create another class from P
|
|
Q = classCopy(P);
|
|
Q.values.q = "null";
|
|
printf(q) {
|
|
print("Object Q : ");
|
|
print(q);
|
|
print("\n");
|
|
}
|
|
Q.functions.printf = printf;
|
|
|
|
// Use of the Q class
|
|
y = new(Q, {x: 1, y: 2, z: 3, q: 42 });
|
|
y.functions.printf(y);
|
|
|
|
nil;
|
|
}
|