Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Super Class method

 
Gina Ruffolo-Daniel
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to print the both the super and subclass methods at the end of my progam. I am just getting subclass data returned.

Super Class


Sub class

Print Line


Thank you for any help in advance,
Gina
 
Raghuveer Kumarakrishnan
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gina ,

Take a look at this method ,your code gets the superclass info allright but what do you with it?? You just return the subclass info in the method. I hope this helped. If not come back ,we are glad to help


[ October 17, 2005: Message edited by: Raghu Kumar ]
 
Gina Ruffolo-Daniel
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to make sure I am understanding correctly: I need to add the info retrieved from Super.getPerson(); to my return statement. How is that done with one return statement? is it Resultreturn Result,Result1?
 
Gina Ruffolo-Daniel
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I got it...
 
Andyjr Robinson
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gina.

Can't you concatenate it into a single string like you are doing elsewhere within your code ??
 
Andyjr Robinson
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you got it !!

But you can do it in a slightly shorter way:

public String getStudent() {
return super.getPerson() + "\nMajor: " + Major + " GPA: " + gpa;
}

And for efficiency you might like to look into The StringBuffer object !!!
 
Gina Ruffolo-Daniel
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I got it...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic