The document defines an abstract base class called "restaurant" with abstract methods for storing, displaying, and payment. It then defines two subclasses "cheque" and "creditcard" that inherit from restaurant and implement the abstract payment method differently for each payment type. The main program creates objects of the cheque and creditcard classes, calls their methods to store data and process a payment, and demonstrates that the subclasses can be referenced by the abstract base class as well.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
36 views2 pages
Class Public Methods
The document defines an abstract base class called "restaurant" with abstract methods for storing, displaying, and payment. It then defines two subclasses "cheque" and "creditcard" that inherit from restaurant and implement the abstract payment method differently for each payment type. The main program creates objects of the cheque and creditcard classes, calls their methods to store data and process a payment, and demonstrates that the subclasses can be referenced by the abstract base class as well.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2
report
z745oops34. Local abstract classes
class restaurant definition abstract.
public section. methods : store, display, payment abstract. protected section. data : tableno type i, steward type string. endclass. class restaurant implementation. method store. tableno = 4. steward = 'ABC'. endmethod. method display. write :/ tableno,steward. endmethod. endclass. class cheque definition inheriting from restaurant. public section. methods payment redefinition. methods m1. protected section. data : cqno type i, cqdate type d, bank type string. endclass. class cheque implementation. method payment. cqno = 533. cqdate = sy-datum. bank = 'SBI'. write :/ cqno,cqdate,bank. endmethod. method m1. write :/ 'inside direct method m1 of subclass cheque'. endmethod. endclass.
class creditcard definition inheriting from restaurant.
public section.
methods payment redefinition.
protected section. data : ccno type i, ccdate type d, bankname type string. endclass. class creditcard implementation. method payment. ccno = 233. ccdate = sy-datum. bankname = 'SBH'. write :/ ccno,ccdate,bankname. endmethod. endclass. start-of-selection. data r type ref to restaurant. *create object r. "not possible write :/ 'Cheque class object....'. data cq type ref to cheque. create object cq. call method : cq->store, cq->display, cq->payment, cq->m1. uline. write :/ 'Cheque class object....---> Abstract class restaurant reference..'. r = cq. call method : r->store, r->display, r->payment, * r->m1. "not possible r->('M1'). "dynamic calling uline. write :/ 'Credit card class object....'. data cc type ref to creditcard. create object cc. call method : cc->store, cc->display, cc->payment.