Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Inheritance + subclasses  RSS feed

 
Mark Do
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, I got an employee abstract class that gives me the first name, last name and social security number:




From this, I want to code another subclass, that defines x number of apples and salary per apples. If the worker reach the target (x number of apples), then the salary of apples (of the excess) will increase by 10%.....if the worker did not reach the target, the salary per apple (less than the target) will decrease by 10%.

Can someone take me through as to how I go about in making another subclass for this?

I tried starting with



But for some reason, the compiler tells me that it is not an abstract and does not overwrite the employee abstract class.

Thanks!
 
Rico Felix
Ranch Hand
Posts: 411
5
IntelliJ IDE Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because the Employee class contains an abstract method public abstract double earnings();

PieceWorkEmployee is forced to provide an implementation for the abstract earnings() method unless you declare PieceWorkEmployee as an abstract class
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark Do wrote: . . . does not overwrite the employee abstract class.

Thanks!
Please post the exact error message in future. I think the compiler said it does not override that method. Fortunately Nico Felix managed to work out what you meant to say: well done
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!