Hi, i have following code:
public class Building {
protected String name;
A(String name){
this.name = name;
}
public void printSpecs() {}
}
and two inherited classes :
public class House extends Building {
protected double maxDimension;
House (String name, double maxDimension) {
super(name);
this.maxDimension= maxDimension;
}
public void printSpecs()
{
System.out.println(maxDimension);
}
}
public class Castle extends Building {
protected double maxWeight;
Castle (String name, double maxWeight) {
super(name);
this.maxDimension= maxWeight;
}
public void printSpecs()
{
System.out.println(maxWeight);
}
}
I have array of objects
HashMap <int, Building > builds = new HashMap<int, Building >();
and some of them are of type "House" and some "Castle"
when i do following:
Building myBuild = builds .get(x);
myBuild.printSpecs();
everything works: specs are printed according to class type.
Now, the question: I want to add function
to "father" class "Building" so that result will be returned by inherited class (similar to function printSpecs)
But, when i add such empty function i get error "function GetSpecs must return results".
So, what's the right syntax/way to do it ?
Thanks