Posted: Fri Sep 21, 2007 5:04 pm Post subject: Polymophism via inheritance
Code:
REPORT s_polymophism_via_inheritance.
* Class Declarations
CLASS ship DEFINITION ABSTRACT.
PUBLIC SECTION.
METHODS: get_max_range ABSTRACT
RETURNING value(r_range) TYPE f,
get_name
RETURNING value(r_name) TYPE string.
PROTECTED SECTION.
DATA name TYPE string.
ENDCLASS.
*
CLASS motorship DEFINITION INHERITING FROM ship.
PUBLIC SECTION.
METHODS: constructor IMPORTING
value(i_name) TYPE string
value(i_fuel_consumption) TYPE f
value(i_fuel_amount) TYPE f,
get_max_range REDEFINITION.
PROTECTED SECTION.
DATA: fuel_consumption TYPE f,
fuel_amount TYPE f.
ENDCLASS.
*
CLASS sailingship DEFINITION INHERITING FROM ship.
PUBLIC SECTION.
METHODS: constructor IMPORTING
value(i_name) TYPE string
value(i_range_per_wind_speed) TYPE f
value(i_wind_speed) TYPE f
value(i_wind_duration) TYPE f,
get_max_range REDEFINITION.
PROTECTED SECTION.
DATA: range_per_wind_speed TYPE f,
wind_speed TYPE f,
wind_duration TYPE f.
ENDCLASS.
* Class Implementations
CLASS ship IMPLEMENTATION.
METHOD get_name.
r_name = name.
ENDMETHOD.
ENDCLASS.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.