• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Problem with abstract methods

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
jon ladd
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
were are u saying thats suppose to go?
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
jon ladd
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
were are u saying thats suppose to go?
 
Ranch Hand
Posts: 3143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you could really do with reading this it might help you out a bit.
 
Oh. Hi guys! Look at this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic