How to design shape class
- by Tomek Tarczynski
I want to design shape class. I need to distinguish several different shapes:
-Point
-Line
-Triangle
-Circle
-Polygons
The main purpose of this class is to calculate distance between two shapes.
I've all methods for calculating those distances, but I want to have a single method that can be used, it should looks like this:
float Distance(Shape a, Shape b)
Simplest way to do it is to put a lot of if statements and then invoke proper method but this is deffinitely not OOP.
How to design such class in OOP style?