Code: Select all
(context 'Account)
(define (make-new nme bal ph)
(println nme " " bal " " ph)
(set 'ctxt (replace " " (upper-case nme) ""))
(new Account 'ctxt)
(set 'ctxt (eval ctxt))
(set 'ctxt:full-name nme 'ctxt:balance bal 'ctxt:phone ph))
(define (Account:deposit amount)
(inc 'balance amount)
(println full-name "'s new balance is " balance))
(define (Account:withdraw amount)
(dec 'balance amount)
(println full-name "'s new balance is " balance))
(define (Account:statement)
(println "Fullname: " full-name)
(println "Balance: " balance))
(context 'MAIN)
(Account:make-new "John Doe" 123.45 "555-555-1212")
called from user defined function Account:make-new
".
What's the problem?
And then, having successfully created dozens of these accounts, how do I iterate across them?