diff options
Diffstat (limited to 'bank-eiffel')
| -rw-r--r-- | bank-eiffel/account.e | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/bank-eiffel/account.e b/bank-eiffel/account.e index 78a293f..39e4167 100644 --- a/bank-eiffel/account.e +++ b/bank-eiffel/account.e | |||
| @@ -58,6 +58,13 @@ feature {NONE} -- Initialization | |||
| 58 | an_interest_deposit_range: ARRAY[REAL_64]; | 58 | an_interest_deposit_range: ARRAY[REAL_64]; |
| 59 | an_interest_debit_range: ARRAY[REAL_64]; | 59 | an_interest_debit_range: ARRAY[REAL_64]; |
| 60 | a_credit_line_range: ARRAY[REAL_64]) | 60 | a_credit_line_range: ARRAY[REAL_64]) |
| 61 | require | ||
| 62 | a_credit_line_range.count() = 2 | ||
| 63 | an_interest_debit_range.count() = 2 | ||
| 64 | an_interest_deposit_range.count() = 2 | ||
| 65 | a_credit_line_range.item (0) < a_credit_line_range.item (1) | ||
| 66 | an_interest_debit_range.item (0) < an_interest_debit_range.item (1) | ||
| 67 | an_interest_deposit_range.item (0) < an_interest_deposit_range.item (1) | ||
| 61 | do | 68 | do |
| 62 | create authorized_signers.make(1) | 69 | create authorized_signers.make(1) |
| 63 | add_authorized_signer (an_authorized_signer) | 70 | add_authorized_signer (an_authorized_signer) |
| @@ -75,9 +82,9 @@ feature -- Basic operations | |||
| 75 | 82 | ||
| 76 | deposit (an_amount: like transfer_minamount; an_authorized_signer: PERSON) | 83 | deposit (an_amount: like transfer_minamount; an_authorized_signer: PERSON) |
| 77 | require | 84 | require |
| 78 | an_authorized_signer_authorized: authorized_signers.has (an_authorized_signer) | 85 | an_authorized_signer_authorized: has_authorized_signer (an_authorized_signer) |
| 79 | an_amount_positive: an_amount > 0.0 | 86 | an_amount_positive: an_amount > 0.0 |
| 80 | transfer_minamount_ok: an_amount >= transfer_minamount | 87 | transfer_minamount_ok: an_amount >= get_transfer_minamount |
| 81 | do | 88 | do |
| 82 | balance := balance + an_amount | 89 | balance := balance + an_amount |
| 83 | ensure | 90 | ensure |
| @@ -87,9 +94,9 @@ feature -- Basic operations | |||
| 87 | 94 | ||
| 88 | withdraw (an_amount: like transfer_minamount; an_authorized_signer: PERSON) | 95 | withdraw (an_amount: like transfer_minamount; an_authorized_signer: PERSON) |
| 89 | require | 96 | require |
| 90 | an_authorized_signer_authorized: authorized_signers.has (an_authorized_signer) | 97 | an_authorized_signer_authorized: has_authorized_signer (an_authorized_signer) |
| 91 | an_amount_positive: an_amount > 0.0 | 98 | an_amount_positive: an_amount > 0.0 |
| 92 | transfer_minamount_ok: an_amount >= transfer_minamount | 99 | transfer_minamount_ok: an_amount >= get_transfer_minamount |
| 93 | do | 100 | do |
| 94 | balance := balance - an_amount | 101 | balance := balance - an_amount |
| 95 | ensure | 102 | ensure |
| @@ -109,7 +116,7 @@ feature -- Basic operations | |||
| 109 | add_authorized_signer (an_authorized_signer: PERSON) | 116 | add_authorized_signer (an_authorized_signer: PERSON) |
| 110 | require | 117 | require |
| 111 | an_authorized_signer_attached: an_authorized_signer /= Void | 118 | an_authorized_signer_attached: an_authorized_signer /= Void |
| 112 | an_authorized_signer_notinlist: not authorized_signers.has (an_authorized_signer) | 119 | an_authorized_signer_notinlist: not has_authorized_signer (an_authorized_signer) |
| 113 | do | 120 | do |
| 114 | authorized_signers.put (an_authorized_signer) | 121 | authorized_signers.put (an_authorized_signer) |
| 115 | ensure | 122 | ensure |
| @@ -119,14 +126,31 @@ feature -- Basic operations | |||
| 119 | remove_authorized_signer (an_authorized_signer: PERSON) | 126 | remove_authorized_signer (an_authorized_signer: PERSON) |
| 120 | require | 127 | require |
| 121 | an_authorized_signer_attached: an_authorized_signer /= Void | 128 | an_authorized_signer_attached: an_authorized_signer /= Void |
| 122 | an_authorized_signer_inlist: authorized_signers.has (an_authorized_signer) | 129 | an_authorized_signer_inlist: has_authorized_signer (an_authorized_signer) |
| 123 | authorized_signers_never_empty: authorized_signers.count >= 2 | 130 | authorized_signers_never_empty: authorized_signers_count >= 2 |
| 124 | do | 131 | do |
| 125 | authorized_signers.prune (an_authorized_signer) | 132 | authorized_signers.prune (an_authorized_signer) |
| 126 | ensure | 133 | ensure |
| 127 | authorized_signers_assigned: not authorized_signers.has (an_authorized_signer) | 134 | authorized_signers_assigned: not authorized_signers.has (an_authorized_signer) |
| 128 | end | 135 | end |
| 129 | 136 | ||
| 137 | has_authorized_signer (an_authorized_signer: PERSON) : BOOLEAN | ||
| 138 | do | ||
| 139 | Result := authorized_signers.has (an_authorized_signer) | ||
| 140 | end | ||
| 141 | |||
| 142 | |||
| 143 | authorized_signers_count : INTEGER | ||
| 144 | do | ||
| 145 | Result := authorized_signers.count | ||
| 146 | end | ||
| 147 | |||
| 148 | get_transfer_minamount : REAL_64 | ||
| 149 | do | ||
| 150 | Result := transfer_minamount | ||
| 151 | end | ||
| 152 | |||
| 153 | |||
| 130 | feature {NONE} -- Implementation | 154 | feature {NONE} -- Implementation |
| 131 | 155 | ||
| 132 | set_transfer_minamount (a_transfer_minamount: like transfer_minamount) | 156 | set_transfer_minamount (a_transfer_minamount: like transfer_minamount) |
| @@ -172,7 +196,6 @@ invariant | |||
| 172 | interest_deposit_within_bounds: | 196 | interest_deposit_within_bounds: |
| 173 | interest_deposit >= interest_deposit_range.item (0) and | 197 | interest_deposit >= interest_deposit_range.item (0) and |
| 174 | interest_deposit <= interest_deposit_range.item (1) | 198 | interest_deposit <= interest_deposit_range.item (1) |
| 175 | interest_deposit_within_bounds: interest_deposit >= 0.0 and interest_deposit <= 1.0 | ||
| 176 | authorized_signers_attached: authorized_signers /= Void | 199 | authorized_signers_attached: authorized_signers /= Void |
| 177 | authorized_signers_not_empty: authorized_signers.count > 0 | 200 | authorized_signers_not_empty: authorized_signers.count > 0 |
| 178 | transfer_minamount_positive: transfer_minamount > 0.0 | 201 | transfer_minamount_positive: transfer_minamount > 0.0 |
