I have a class that has overloaded methods.
public class MyCal extends GregorianCalendar {
//constructor
public MyCal(Date date) {
super();
setTime(date);
}
boolean isSameDay(Date date) {
return (isSameDay(new MyCal(date))) {
}
boolean isSameDay(MyCal cal) {
if (...) {
return true;
} else {
return false;
}
}
//abstract String toString(String pattern) {};
//if I have this I can't call new MyCal(date) from above
}
Now I want the class to be abstract (need the sub classes to implement a few other methods), and still avoid all the logic of the first isSameDay method (calling the second one). If it was just this method it would be ok I could do it, but this situation is replicated on many other overloaded methods.
The class being abstract I can’t instantiate it and so the method isSameDay(date) will report an error… and really don’t want to have the logic on all methods, it would make the class enormous as well as harder to maintain.
Can anybody have a good way of doing this?
Thank you in advance.
I think that what he means is that he wants to instantiate an object of the derived class in the parent class.
I suggest doing something like this:
Parent Class
Derived Class
Pardon my possible java syntax mistakes….