(define (make-account balance password)
(define (withdraw amount)
(if (>= balance amount)
(begin (set! balance (- balance amount))
balance)
"Insufficient amount"))
(define (deposit amount)
(begin (set! balance (+ balance amount))
balance))
(define (dispatch m)
(cond ((eq? m 'joint) set-password)
((eq? m 'withdraw) withdraw)
((eq? m 'deposit) deposit)
(else
(error "Unknow request --- MAKE-ACCOUNT" m))))
(define (set-password password)
(define (validate psw op)
(if (eq? psw password)
(dispatch op)
(error "Incorrect password")))
validate)
(set-password password))
(define (make-joint account origin-password new-password)
((account origin-password 'joint) new-password))
(define acc (make-account 100 'ssd))
(define acc-alias (make-joint acc 'ssd 'kk))
((acc 'ssd 'withdraw) 20)
((acc 'ssd 'withdraw) 30)
((acc-alias 'kk 'withdraw) 10)
((acc-alias 'kk 'deposit) 60)
((acc 'ssd 'withdraw) 0)