Generics won’t solve that, as addPoint can be make to accept either type… but once it has started to accept ONE type, it should then not be allowed to accept the other
accept any type as input
in the addpoint method, check the parameter input type
if it is not one that is already in the point list of the method, then reject with an exception or an error code
I’ve re-read the thread and think I didn’t fully understand what you’re trying to accomplish.
So my thoughts are this.
Context Switches of any kind in the addPoint function are not going to give you what you want, and they will consume CPU time when not needed.
Subclassing should allow this. You create one subclass that can take a number, and one subclass that can take a date. You name the different functions for each subclass, this way at design time it’s clear which class you’re using and therefore you’re less likely to pass in a date to a class that doesn’t accept a date.