aspose file tools*
The moose likes Beginning Java and the fly likes Problem with abstract methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Problem with abstract methods" Watch "Problem with abstract methods" New topic
Author

Problem with abstract methods

jon ladd
Ranch Hand

Joined: Feb 11, 2003
Posts: 53
Its giveing me these errors "Class Employee should be declared abstract; it does not define method fullname() in class Employee at line 128"
andClass Customer should be declared abstract; it does not define method fullname() in class Customer at line 161. There not suppose to be abstrac just the Person class is.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
You have to provide an implementation for public abstract void fullname() in order for the Employee class to be concrete (that is not abstract). So do something like this in Employee:

[ April 29, 2003: Message edited by: Michael Morris ]

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
jon ladd
Ranch Hand

Joined: Feb 11, 2003
Posts: 53
I have this is on my employee class and my customer class.
public String toString() {
String result = fullname() + ", " + getPrate() ;
return result;
and it gives me this error 'void' type not allowed here at line 161
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
The toString method does not provide a method body for fullname. Aparrantly the return type is also incorrectly declared in the Parent class. It should be public abstract String fullname(). In that case the method could be defined something like this in the Employee class:

[ April 29, 2003: Message edited by: Michael Morris ]
jon ladd
Ranch Hand

Joined: Feb 11, 2003
Posts: 53
were are u saying thats suppose to go?
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
I don't think fullname() should even be abstract since every Person has full name, whether they are a Customer or an Employee. In other words, imho, the fullname() function that Michael gave should go in the Person class. If the Customer wants to do something different for its fullname() then Customer should have its own fullname() method that does the customizations necessary for a Customer.
HTH
Layne


Java API Documentation
The Java Tutorial
jon ladd
Ranch Hand

Joined: Feb 11, 2003
Posts: 53
were are u saying thats suppose to go?
Angela Poynton
Ranch Hand

Joined: Mar 02, 2000
Posts: 3143
I think you could really do with reading this it might help you out a bit.


Pounding at a thick stone wall won't move it, sometimes, you need to step back to see the way around.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with abstract methods