Skip to content

Lesson 4 Practice — Bank Account Object ​

Create:

text
ZCL_BANK_ACCOUNT_###
ZCL_ABAP_L04_PRACTICE_###

Bank Account state ​

Keep private:

text
account_id
owner_name
balance

Public API ​

Create:

text
constructor
deposit
withdraw
get_account_id
get_owner_name
get_balance

Rules:

text
initial balance cannot be negative
deposit must be > 0
withdraw must be > 0
withdraw cannot exceed balance

withdraw should return abap_bool indicating success.

Runner ​

Create at least two accounts and prove their balances are independent.

Questions ​

  1. Why is balance private?
  2. Why is withdraw better than a generic set_balance?
  3. What does NEW return?
  4. What does -> mean?
  5. What is the difference between a class and an object?