Let's say I have a 2DPosition class:
double x;
double y;
void update(double x, double y) { ... }
double getX() { ... }
double getY() { ... }
a 3DPosition class:
double x;
double y;
double z;
void update(double x, double y, double z) { ... }
double getX() { ... }
double getY() { ... }
double getZ() { ... }
and so on. An object may need to use one of these implementations, so a common Interface is required. What is the best way to design such thing?
Aucun commentaire:
Enregistrer un commentaire