There is an interface Accountable
which has 2 methods. There are 9 classes which implement the Accountable
interface.
public interface Accountable{
boolean isAccountable();
float getWorth();
}
We have got a new requirement as follows: Two more methods declarations to be added to the interface. But we need to minimize the effect on the existing classes. I was told that we can use Adaptors to resolve the issue. But I am not sure how to do it. Could anyone please help me solve the issue?
Using java 8 you can declare default implementation just in interface:
public interface Accountable{
boolean isAccountable();
float getWorth();
default int someMethod() {return 0;}
}
If you use old java the only way is to add an abstract class as a middlware, but since java don't support multiple inheritance it could be painful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With