public abstract class AdicionalesCpd extends Cpd{
public abstract int getCpu();
public abstract int getRam();
public abstract int getDisco();
public abstract String getCadena();}
This my abstract class for the decorator pattern, and I have this problem when it compiles:
**error: Cpu is not abstract and does not override abstract method getCadena() in AdicionalesCpd
public class Cpu extends AdicionalesCpd{ ** I don't know why doesn't override the method "getCpu"
This is my Cpu class which is a "decoration" in the pattern
public class Cpu extends AdicionalesCpd{
Cpd cpd;
int var;
public Cpu(Cpd cpd,int var)
{
this.cpd=cpd;
this.var=var;
}
@Override
public int getCpu() {
return cpd.getCpu()+var;
}
}
Your abstract base type defines four abstract methods:
Your concrete derived type implements one of them:
The error is telling you that you have to implement all of them. Otherwise, what would happen when code invokes one of those methods on an instance of the concrete type?