Results 1 to 2 of 2
Thread: I want to add function
- 07-17-2007, 03:13 PM #1
Member
- Join Date
- Jul 2007
- Posts
- 26
- Rep Power
- 0
I want to add function
Hi, i have following code:
and two inherited classes :Java Code:public class Building { protected String name; A(String name){ this.name = name; } public void printSpecs() {} }
I have array of objectsJava Code: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); } }
and some of them are of type "House" and some "Castle"Java Code:HashMap <int, Building > builds = new HashMap<int, Building >();
when i do following:
everything works: specs are printed according to class type.Java Code:Building myBuild = builds .get(x); myBuild.printSpecs();
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)Java Code:int GetSpecs() {}
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
- 08-07-2007, 05:25 AM #2
Member
- Join Date
- Jul 2007
- Posts
- 40
- Rep Power
- 0
Similar Threads
-
use of onclick function
By m4tt in forum New To JavaReplies: 1Last Post: 02-16-2008, 03:03 AM -
How to use a function in java
By olikhvar in forum New To JavaReplies: 2Last Post: 02-16-2008, 02:57 AM -
Need a little help with a function!
By Nuluvius in forum New To JavaReplies: 3Last Post: 02-07-2008, 11:33 PM -
function name
By osval in forum Advanced JavaReplies: 1Last Post: 08-06-2007, 08:56 PM -
Help with the Dummy Function
By Felissa in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 07-06-2007, 05:03 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks