;; Die ersten drei Zeilen dieser Datei wurden von DrRacket eingefügt. Sie enthalten Metadaten ;; über die Sprachebene dieser Datei in einer Form, die DrRacket verarbeiten kann. #reader(lib "DMdA-assignments-reader.ss" "deinprogramm")((modname account-mutable-record) (read-case-sensitive #f) (teachpacks ()) (deinprogramm-settings #(#f write repeating-decimal #t #t none explicit #f ()))) ; Ein veränderbares Bankkonto besteht aus ; - einem veränderbaren Kontostand (real) (define-record-procedures-2 account make-account account? ((account-balance set-account-balance!))) (: make-account (real -> account)) (: account? (any -> boolean)) (: account-balance (account -> real)) (: set-account-balance! (account real -> unspecific)) (define A1 (make-account 120)) ; Von einem Konto abheben (: account-withdraw! (account real -> real)) (define account-withdraw! (lambda (acct amount) (if (>= (account-balance acct) amount) (begin (set-account-balance! acct (- (account-balance acct) amount)) (account-balance acct)) (violation "No money!")))) ; Auf ein Konto einzahlen (: account-deposit! (account real -> real)) (define account-deposit! (lambda (acct amount) (begin (set-account-balance! acct (+ (account-balance acct) amount)) (account-balance acct)))) ; Geldbetrag von einem Konto auf ein anderes transferieren: (: transfer-money (account account real -> unspecific)) (define transfer-money (lambda (acct1 acct2 amount) (begin (account-withdraw! acct1 money) (account-deposit! acct2 money))))