‎2006 Apr 30 1:29 PM
Hello. I have a base class called Property. It gets data from the program in the form of a parameter p_data. There are 2 methods getdata(gets p_data from the program) and display_area(calculate and print the area)
I have two subclasses called FootballPitch and RaceTrack which are inheriting from Property. There are two methods: Pitch_area(calculate the area using p_data) and display_pitch(this redefines display_area in the super class).
The second subclass will work in a similar way. I am new to classes in ABAP so I need some assistance. Thank you.
James
‎2006 Apr 30 1:59 PM
Hi James,
Welcome to SDN!!
Can u tell us in what way would u need assistance..
If syntax is the problem...
refer
This shall help u solve your problem and is excellent tutorial for freshers.
Was of great help to me too.
Hope that helps!!
Let me know your email id and i shall mail the documents to you alonf with some good documents
Regards,
Tanveer.
Please mark answers by clicking on the star at the top
‎2006 Apr 30 4:12 PM
I would like to know how to use pitch_area to redefine display_area. What will the method look like? It seems to me that pitch_area is not needed.
James
‎2006 Apr 30 6:48 PM
Hi James,
Well, you understood that nicely.See the only important thing to do is to redefine the display_area method.Here u CANNOT CHANGE THE METHOD INTERFACE, whereas you are free to change code according to your need.
Hope this helps.
best regards,
Bharat
‎2006 Apr 30 9:28 PM
Hello James,
You have got it right!!
Both the methods pitch_area and display_area i suppose do the calculation of area based on parameter p_data.
So you need not override (what u termed as redefine) the method display_area.
Also a method pitch_area cannot override display_area.
It need to be so same interface.
For example,
if u declare your display_area method as follows in base class Property :
method display_area .
area = p_data * p_data.
endmethod.
Now if u use this method in the child class FootballPitch,
it will do the same work of finding area..
U can overide it here..
method display_area .
area = 2 * p_data * p_data.
endmethod.
Now when u use this method, it will give u 2 times the area .
However, for class RaceTrack,
the method display_area would still give u the area..
Hope that explains th point..
Shall mail u documents on this topic once i get back to office on tuesday...
Regards,
Tanveer.
Note: Please mark helpful answers on SDN as thats the only way to appreciate someones efforts..
‎2006 May 02 12:46 AM
I used redefined the original method in the subclasses. Pitch_area was not necessary as I thought.
Thank you all for the help. However, I don't see the radio buttons to award the points to you for helping me.
James