I have a few subclasses of Shape:
Rectangle, Circle, etc.
I also have a methods in each class like this:
class Rectangle extends Shape{
public void isIntersecting(Circle circle){ ... }
}
class Circle extends Shape{
public void isIntersecting(Rectangle rectangle){ ... }
}
These methods obviously would be repeated code. My question is, how do I avoid something like this?
You could implement them once (in either class or as a static method somewhere) and have all methods call that shared code.