| Author |
Super Class method
|
Gina Ruffolo-Daniel
Greenhorn
Joined: Oct 01, 2005
Posts: 19
|
|
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
Joined: Mar 13, 2005
Posts: 32
|
|
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 ]
|
Raghu<br />SCJP 1.4<br />SCWCD 1.4<br />SCBCD 1.3
|
 |
Gina Ruffolo-Daniel
Greenhorn
Joined: Oct 01, 2005
Posts: 19
|
|
|
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
Joined: Oct 01, 2005
Posts: 19
|
|
I think I got it...
|
 |
Andyjr Robinson
Greenhorn
Joined: Oct 12, 2005
Posts: 6
|
|
Gina. Can't you concatenate it into a single string like you are doing elsewhere within your code ??
|
 |
Andyjr Robinson
Greenhorn
Joined: Oct 12, 2005
Posts: 6
|
|
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
Joined: Oct 01, 2005
Posts: 19
|
|
I think I got it...
|
 |
 |
|
|
subject: Super Class method
|
|
|