Hiding class code from students
I am creating step by step Processing code examples to introduce novice programmers to object oriented programming. I have written a number of examples where the code for a Circle class is in a separate tab from the main programme. The idea is for students to use the appropriate methods from the class code but without being able to see the underlying code - i.e. to be introduced to the use of objects of the class without worrying about the implementation code. As it stands inquisitive students can click on the Circle tab and see the code. This is fine for students ready to move on to it but might dismay their slower colleagues. My intention was to compile it and add it as a library. I have spent some time trying various approaches but I think maybe I don't understand the use of jar files etc.
Could anyone point me in the right direction?
I attach the code for my first example to illustrate
Thanks in advance!
Ken Brownsey
// Main
Circle C = new Circle(200, 300, 50, 0, 0, 0);
void setup() {
size(500, 500);
C.Draw();
}
// Circle class in separate tab
class Circle {
int Cx,
Cy;
int dx,
dy;
int D;
color FillCol;
Circle(int Cx, int Cy, int D, color FillCol, int dx, int dy) {
this.Cx = Cx;
this.Cy = Cy;
this.dx = dx;
this.dy = dy;
this.D = D;
this.FillCol = FillCol;
}
// PRE TRUE
// POST Circle drawn on canvas
void Draw() {
fill(FillCol);
ellipse(Cx, Cy, D, D);
}
// PRE TRUE
// POST Moves this (dx, dy)
void Move() {
Cx += dx;
Cy += dy;
}
}