Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Implementing an Abstract method

 
rob starteren
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i have been given a Team class and was asked to make a subclass RugbyTeam from it.

The only abstract method in Team i have to implement is




I know how to implement it, the only thing conufusing me is the parameter variable name iProblemsSolved. For the rugby subclass should have a parameter name called goalsScored not iProblemsSolved because rugby teams score goals. Is it ok to rename this new methods parameter variable goalsScored in the RugbyTeam subclass or is this against convention.
eg.

It compiles fine as you will know. Or should the Team class abstract methods parameter variable name be renamed to comething more generic like pointsScored?

eg.


Can i have straight forward answers please, no "i think" answers. Was getting them on another forum which confused me more.
 
Alexis Michael
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Parameter names do not matter. As long as the return type, function name, and parameter type as the same, you are on the safe side.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it ok to rename this new methods parameter variable goalsScored

Yes, it is ok.

Or should the Team class abstract methods parameter variable name be renamed to comething more generic like pointsScored?

It may be a matter of taste I prefer to leave the abstract name as is.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic