vendredi 16 août 2019

Designing C++ Class

I'm a student learning C++ and I'm working on a project where I have two classes called MotionControl and Axis.

The MotionControl class has three Axis objects:

Axis *x;
Axis *y;
Axis *z;

My Axis class currently has these two functions:

void move(int position)

this moves an axis to the position

int getPosition()

this gets the position of an axis

Now, I want to modify my program so that when I try to move the z axis, I will check whether the x and y position falls in a certain range before moving to a z position. However, moving the x axis or the y axis should retain the same behavior as before i.e. it should just move the axis to the position.

I have thought of creating a new class, etc. but I can't come up with a solution that will work. How can I go about doing this?

Aucun commentaire:

Enregistrer un commentaire