CUSTOMER class
class
CUSTOMER
create
make
feature{NONE} -- Creation
make(a_name:STRING)
-- Create a customer with an `account'
local
l_account: ACCOUNT
l_name: IMMUTABLE_STRING_8
l_bank: BANK
do
l_name := a_name
name := l_name
create l_account.make_with_name (a_name)
create l_bank.make
b := l_bank
account := l_account
ensure
correct_name: name ~ a_name
correct_balance: balance = balance.zero
end
feature -- queries
name: IMMUTABLE_STRING_8
balance: VALUE
do
Result := account.balance
end
account: ACCOUNT
b: BANK
invariant
name_consistency: name ~ account.name
balance_consistency: balance = account.balance
end
part of BANK class:
make -- make a bank
do
count := 0
create [ARRAY_LIST][CUSTOMER] customers.make(10)
customers.count.set_Item(10)
end
new(name1: STRING) -- add a new customer to bank
require
....
local
c: CUSTOMER
do
create c.make(name1)
customers.extend(c)
count := count + 1
ensure
...
end
I get a check assertion error from ARRAY_LIST class when trying to put a customer in the array. The tag i get is "valid_index" I don't know why its wrong because the index is right and I set the count for the array and give the correct index.
customers is of type CUSTOMER class
bank has customers and customers have accounts
CUSTOMER has an ACCOUNT class