diff options
| -rw-r--r-- | bank-eiffel/account.e | 13 | ||||
| -rw-r--r-- | bank-eiffel/bank.e | 387 | ||||
| -rw-r--r-- | bank-eiffel/retireeaccount.e | 13 | ||||
| -rw-r--r-- | bank-eiffel/studentaccount.e | 13 |
4 files changed, 388 insertions, 38 deletions
diff --git a/bank-eiffel/account.e b/bank-eiffel/account.e index fe9cc3b..a6e30ef 100644 --- a/bank-eiffel/account.e +++ b/bank-eiffel/account.e | |||
| @@ -81,16 +81,19 @@ feature -- Basic operations | |||
| 81 | require | 81 | require |
| 82 | an_authorized_signer_authorized: get_authorized_signers.has (an_authorized_signer) | 82 | an_authorized_signer_authorized: get_authorized_signers.has (an_authorized_signer) |
| 83 | transfer_minamount_ok: an_amount >= transfer_minamount | 83 | transfer_minamount_ok: an_amount >= transfer_minamount |
| 84 | balance_beneath_creditline: balance - an_amount >= creditline | ||
| 84 | do | 85 | do |
| 85 | balance := balance - an_amount | 86 | balance := balance - an_amount |
| 86 | ensure | 87 | ensure |
| 88 | balance_beneath_creditline: balance >= creditline | ||
| 87 | balance_decreased: balance < old balance | 89 | balance_decreased: balance < old balance |
| 88 | withdrawed: balance = old balance - an_amount | 90 | withdrawed: balance = old balance - an_amount |
| 89 | balance_beneath_creditline: balance >= creditline | ||
| 90 | end | 91 | end |
| 91 | 92 | ||
| 92 | transfer(an_amount: like transfer_minamount; an_authorized_signer: PERSON; | 93 | transfer(an_amount: like transfer_minamount; an_authorized_signer: PERSON; |
| 93 | an_account: like Current; another_authorized_signer: PERSON) | 94 | an_account: like Current; another_authorized_signer: PERSON) |
| 95 | require | ||
| 96 | recipient_account_not_same: Current /= an_account | ||
| 94 | do | 97 | do |
| 95 | withdraw (an_amount, an_authorized_signer) | 98 | withdraw (an_amount, an_authorized_signer) |
| 96 | an_account.deposit (an_amount, another_authorized_signer) | 99 | an_account.deposit (an_amount, another_authorized_signer) |
| @@ -107,12 +110,10 @@ feature -- Basic operations | |||
| 107 | 110 | ||
| 108 | remove_authorized_signer (an_authorized_signer: PERSON) | 111 | remove_authorized_signer (an_authorized_signer: PERSON) |
| 109 | require | 112 | require |
| 110 | authorized_signers_never_empty: (get_authorized_signers.has (an_authorized_signer) | 113 | authorized_signer_exists: (get_authorized_signers.has (an_authorized_signer)) |
| 111 | and get_authorized_signers.count >= 2) or True | 114 | authorized_signers_not_empty: get_authorized_signers.count >= 2 |
| 112 | do | 115 | do |
| 113 | if authorized_signers.has (an_authorized_signer) then | 116 | authorized_signers.prune (an_authorized_signer) |
| 114 | authorized_signers.prune (an_authorized_signer) | ||
| 115 | end | ||
| 116 | ensure | 117 | ensure |
| 117 | authorized_signers_assigned: not authorized_signers.has (an_authorized_signer) | 118 | authorized_signers_assigned: not authorized_signers.has (an_authorized_signer) |
| 118 | end | 119 | end |
diff --git a/bank-eiffel/bank.e b/bank-eiffel/bank.e index 523878b..223f60f 100644 --- a/bank-eiffel/bank.e +++ b/bank-eiffel/bank.e | |||
| @@ -66,7 +66,7 @@ feature -- Basic operations | |||
| 66 | print_last_error | 66 | print_last_error |
| 67 | do | 67 | do |
| 68 | if not last_error.is_empty then | 68 | if not last_error.is_empty then |
| 69 | print ("Error: " + last_error + "%N%N") | 69 | print (last_error + "%N%N") |
| 70 | last_error := "" | 70 | last_error := "" |
| 71 | end | 71 | end |
| 72 | end | 72 | end |
| @@ -182,17 +182,41 @@ feature -- Basic operations | |||
| 182 | end | 182 | end |
| 183 | 183 | ||
| 184 | edit_range(type: STRING_8; range: like {BANK_STORE}.range) | 184 | edit_range(type: STRING_8; range: like {BANK_STORE}.range) |
| 185 | local | ||
| 186 | back: BOOLEAN | ||
| 185 | do | 187 | do |
| 186 | print ("Enter " + type + " minimum [" + fd.formatted(range.min) + "]: ") | 188 | from |
| 187 | io.readline | 189 | back := False |
| 188 | if io.last_string.is_double then | 190 | until |
| 189 | range.min := io.last_string.to_double | 191 | back |
| 192 | loop | ||
| 193 | print ("Enter " + type + " minimum [" + fd.formatted(range.min) + "]: ") | ||
| 194 | io.readline | ||
| 195 | if io.last_string.is_double then | ||
| 196 | range.min := io.last_string.to_double | ||
| 197 | back := True | ||
| 198 | elseif io.last_string.is_empty then | ||
| 199 | back := True | ||
| 200 | else | ||
| 201 | print ("Invalid value%N") | ||
| 202 | end | ||
| 190 | end | 203 | end |
| 191 | 204 | ||
| 192 | print ("Enter " + type + " maximum [" + fd.formatted(range.max) + "]: ") | 205 | from |
| 193 | io.readline | 206 | back := False |
| 194 | if io.last_string.is_double then | 207 | until |
| 195 | range.max := io.last_string.to_double | 208 | back |
| 209 | loop | ||
| 210 | print ("Enter " + type + " maximum [" + fd.formatted(range.max) + "]: ") | ||
| 211 | io.readline | ||
| 212 | if io.last_string.is_double then | ||
| 213 | range.max := io.last_string.to_double | ||
| 214 | back := True | ||
| 215 | elseif io.last_string.is_empty then | ||
| 216 | back := True | ||
| 217 | else | ||
| 218 | print ("Invalid value%N") | ||
| 219 | end | ||
| 196 | end | 220 | end |
| 197 | end | 221 | end |
| 198 | 222 | ||
| @@ -348,12 +372,12 @@ feature -- Basic operations | |||
| 348 | last_error := "Person (#" + num.out + ") edited successfully" | 372 | last_error := "Person (#" + num.out + ") edited successfully" |
| 349 | back := True | 373 | back := True |
| 350 | else | 374 | else |
| 351 | last_error := "Invalid person id" | 375 | last_error := "Error: Invalid person id" |
| 352 | end | 376 | end |
| 353 | elseif io.last_string.is_equal ("b") then | 377 | elseif io.last_string.is_equal ("b") then |
| 354 | back := True | 378 | back := True |
| 355 | else | 379 | else |
| 356 | last_error := "Not a number" | 380 | last_error := "Error: Not a number" |
| 357 | end | 381 | end |
| 358 | end | 382 | end |
| 359 | end | 383 | end |
| @@ -378,12 +402,12 @@ feature -- Basic operations | |||
| 378 | last_error := "Person (#" + io.last_string + ") removed successfully" | 402 | last_error := "Person (#" + io.last_string + ") removed successfully" |
| 379 | back := True | 403 | back := True |
| 380 | else | 404 | else |
| 381 | last_error := "Invalid person id" | 405 | last_error := "Error: Invalid person id" |
| 382 | end | 406 | end |
| 383 | elseif io.last_string.is_equal ("b") then | 407 | elseif io.last_string.is_equal ("b") then |
| 384 | back := True | 408 | back := True |
| 385 | else | 409 | else |
| 386 | last_error := "Not a number" | 410 | last_error := "Error: Not a number" |
| 387 | end | 411 | end |
| 388 | end | 412 | end |
| 389 | end | 413 | end |
| @@ -432,12 +456,12 @@ feature -- Basic operations | |||
| 432 | io.read_line | 456 | io.read_line |
| 433 | done := True | 457 | done := True |
| 434 | else | 458 | else |
| 435 | print ("Invalid account id%N%N") | 459 | print ("Error: Invalid account id%N%N") |
| 436 | end | 460 | end |
| 437 | elseif io.last_string.is_equal("b") then | 461 | elseif io.last_string.is_equal("b") then |
| 438 | done := True | 462 | done := True |
| 439 | else | 463 | else |
| 440 | print ("Not a number%N%N") | 464 | print ("Error: Not a number%N%N") |
| 441 | end | 465 | end |
| 442 | end | 466 | end |
| 443 | when 'c' then | 467 | when 'c' then |
| @@ -500,6 +524,7 @@ feature -- Basic operations | |||
| 500 | print (" - Interest deposit: " + fd.formatted(account.interest_deposit) + " " + print_range(range.interest_deposit) + "%N") | 524 | print (" - Interest deposit: " + fd.formatted(account.interest_deposit) + " " + print_range(range.interest_deposit) + "%N") |
| 501 | print (" - Interest debit: " + fd.formatted(account.interest_debit) + " " + print_range(range.interest_debit) +"%N") | 525 | print (" - Interest debit: " + fd.formatted(account.interest_debit) + " " + print_range(range.interest_debit) +"%N") |
| 502 | print (" - Creditline: " + fd.formatted(account.creditline) + " " + print_range(range.creditline) +"%N") | 526 | print (" - Creditline: " + fd.formatted(account.creditline) + " " + print_range(range.creditline) +"%N") |
| 527 | print (" - Minimum transfer amount: " + fd.formatted(account.transfer_minamount) +"%N") | ||
| 503 | print (" - Authorized signers:%N") | 528 | print (" - Authorized signers:%N") |
| 504 | from | 529 | from |
| 505 | account.get_authorized_signers.linear_representation.start | 530 | account.get_authorized_signers.linear_representation.start |
| @@ -597,12 +622,12 @@ feature -- Basic operations | |||
| 597 | store.persons.go_i_th (io.last_string.to_integer) | 622 | store.persons.go_i_th (io.last_string.to_integer) |
| 598 | next := True | 623 | next := True |
| 599 | else | 624 | else |
| 600 | print ("Invalid person id%N%N") | 625 | print ("Error: Invalid person id%N%N") |
| 601 | end | 626 | end |
| 602 | elseif io.last_string.is_equal ("b") then | 627 | elseif io.last_string.is_equal ("b") then |
| 603 | back := True | 628 | back := True |
| 604 | else | 629 | else |
| 605 | print ("Not a number%N%N") | 630 | print ("Error: Not a number%N%N") |
| 606 | end | 631 | end |
| 607 | end | 632 | end |
| 608 | 633 | ||
| @@ -622,7 +647,7 @@ feature -- Basic operations | |||
| 622 | elseif io.last_string.is_equal ("b") then | 647 | elseif io.last_string.is_equal ("b") then |
| 623 | back := True | 648 | back := True |
| 624 | else | 649 | else |
| 625 | print ("Invalid interest deposit number%N%N") | 650 | print ("Error: Invalid interest deposit number%N%N") |
| 626 | end | 651 | end |
| 627 | end | 652 | end |
| 628 | 653 | ||
| @@ -642,7 +667,7 @@ feature -- Basic operations | |||
| 642 | elseif io.last_string.is_equal ("b") then | 667 | elseif io.last_string.is_equal ("b") then |
| 643 | back := True | 668 | back := True |
| 644 | else | 669 | else |
| 645 | print ("Invalid interest debit number%N%N") | 670 | print ("Error: Invalid interest debit number%N%N") |
| 646 | end | 671 | end |
| 647 | end | 672 | end |
| 648 | 673 | ||
| @@ -662,7 +687,7 @@ feature -- Basic operations | |||
| 662 | elseif io.last_string.is_equal ("b") then | 687 | elseif io.last_string.is_equal ("b") then |
| 663 | back := True | 688 | back := True |
| 664 | else | 689 | else |
| 665 | print ("Invalid creditline number%N%N") | 690 | print ("Error: Invalid creditline number%N%N") |
| 666 | end | 691 | end |
| 667 | end | 692 | end |
| 668 | 693 | ||
| @@ -707,12 +732,12 @@ feature -- Basic operations | |||
| 707 | edit_account(store.accounts.index, store.accounts.item) | 732 | edit_account(store.accounts.index, store.accounts.item) |
| 708 | back := True | 733 | back := True |
| 709 | else | 734 | else |
| 710 | last_error := "Invalid account id" | 735 | last_error := "Error: Invalid account id" |
| 711 | end | 736 | end |
| 712 | elseif io.last_string.is_equal ("b") then | 737 | elseif io.last_string.is_equal ("b") then |
| 713 | back := True | 738 | back := True |
| 714 | else | 739 | else |
| 715 | last_error := "Not a number" | 740 | last_error := "Error: Not a number" |
| 716 | end | 741 | end |
| 717 | end | 742 | end |
| 718 | end | 743 | end |
| @@ -733,12 +758,13 @@ feature -- Basic operations | |||
| 733 | print (" 1 ...edit interest deposit%N") | 758 | print (" 1 ...edit interest deposit%N") |
| 734 | print (" 2 ...edit interest debit%N") | 759 | print (" 2 ...edit interest debit%N") |
| 735 | print (" 3 ...edit creditline%N") | 760 | print (" 3 ...edit creditline%N") |
| 736 | print (" 4 ...add authorized signer%N") | 761 | print (" 4 ...edit minimum transfer amount%N") |
| 737 | print (" 5 ...remove authorized signer%N") | 762 | print (" 5 ...add authorized signer%N") |
| 738 | print (" 6 ...deposit%N") | 763 | print (" 6 ...remove authorized signer%N") |
| 739 | print (" 7 ...withdraw%N") | 764 | print (" 7 ...deposit%N") |
| 740 | print (" 8 ...transfer%N") | 765 | print (" 8 ...withdraw%N") |
| 741 | print (" 9 ...advance%N") | 766 | print (" 9 ...transfer%N") |
| 767 | print (" 0 ...advance%N") | ||
| 742 | print (" b ...back%N") | 768 | print (" b ...back%N") |
| 743 | print ("%N") | 769 | print ("%N") |
| 744 | print_last_error | 770 | print_last_error |
| @@ -748,14 +774,40 @@ feature -- Basic operations | |||
| 748 | 774 | ||
| 749 | inspect io.last_character.lower | 775 | inspect io.last_character.lower |
| 750 | when '1' then | 776 | when '1' then |
| 777 | account.interest_deposit := edit_account_detail_double("interest deposit", account.interest_deposit) | ||
| 778 | last_error := "Interest deposit changed successfully" | ||
| 751 | when '2' then | 779 | when '2' then |
| 780 | account.interest_debit := edit_account_detail_double("interest debit", account.interest_debit) | ||
| 781 | last_error := "Interest debit changed successfully" | ||
| 752 | when '3' then | 782 | when '3' then |
| 783 | account.creditline := edit_account_detail_double("creditline", account.creditline) | ||
| 784 | last_error := "Creditline changed successfully" | ||
| 753 | when '4' then | 785 | when '4' then |
| 786 | account.transfer_minamount := edit_account_detail_double("transfer miniumum amount", account.transfer_minamount) | ||
| 787 | last_error := "Transfer minimum amount changed successfully" | ||
| 754 | when '5' then | 788 | when '5' then |
| 789 | if edit_account_add_asigner (account) then | ||
| 790 | last_error := "Authorized signer added successfully" | ||
| 791 | end | ||
| 755 | when '6' then | 792 | when '6' then |
| 793 | if edit_account_remove_asigner (account) then | ||
| 794 | last_error := "Authorized signer removed successfully" | ||
| 795 | end | ||
| 756 | when '7' then | 796 | when '7' then |
| 797 | if edit_account_deposit (account) then | ||
| 798 | last_error := "Deposit successfully" | ||
| 799 | end | ||
| 757 | when '8' then | 800 | when '8' then |
| 801 | if edit_account_withdraw (account) then | ||
| 802 | last_error := "Widthdraw successfully" | ||
| 803 | end | ||
| 758 | when '9' then | 804 | when '9' then |
| 805 | if edit_account_transfer (account) then | ||
| 806 | last_error := "Transfer successfully" | ||
| 807 | end | ||
| 808 | when '0' then | ||
| 809 | account.advance | ||
| 810 | last_error := "Account advanced successfully" | ||
| 759 | when 'b' then | 811 | when 'b' then |
| 760 | back := True | 812 | back := True |
| 761 | else | 813 | else |
| @@ -763,6 +815,281 @@ feature -- Basic operations | |||
| 763 | end | 815 | end |
| 764 | print ("%N%N") | 816 | print ("%N%N") |
| 765 | end | 817 | end |
| 818 | rescue | ||
| 819 | if not (create {EXCEPTIONS}).is_signal then | ||
| 820 | last_error := "Exception: " + (create {EXCEPTIONS}).tag_name | ||
| 821 | retry | ||
| 822 | end | ||
| 823 | end | ||
| 824 | |||
| 825 | edit_account_detail_double(type: STRING_8; val: REAL_64): REAL_64 | ||
| 826 | local | ||
| 827 | back: BOOLEAN | ||
| 828 | do | ||
| 829 | Result := val | ||
| 830 | from | ||
| 831 | until | ||
| 832 | back | ||
| 833 | loop | ||
| 834 | print ("Enter " + type + " [" + fd.formatted(val) + "]: ") | ||
| 835 | io.readline | ||
| 836 | if io.last_string.is_double then | ||
| 837 | Result := io.last_string.to_double | ||
| 838 | back := True | ||
| 839 | elseif io.last_string.is_empty then | ||
| 840 | back := True | ||
| 841 | else | ||
| 842 | print ("Error: Invalid value%N") | ||
| 843 | end | ||
| 844 | end | ||
| 845 | end | ||
| 846 | |||
| 847 | edit_account_add_asigner(account: ACCOUNT): BOOLEAN | ||
| 848 | local | ||
| 849 | back: BOOLEAN | ||
| 850 | do | ||
| 851 | Result := False | ||
| 852 | from | ||
| 853 | list_persons | ||
| 854 | until | ||
| 855 | back | ||
| 856 | loop | ||
| 857 | print_last_error | ||
| 858 | print ("Enter person (authorized signer) id (b ...back): ") | ||
| 859 | io.readline | ||
| 860 | io.last_string.to_lower | ||
| 861 | if io.last_string.is_integer then | ||
| 862 | if store.persons.valid_index (io.last_string.to_integer) then | ||
| 863 | store.persons.go_i_th(io.last_string.to_integer) | ||
| 864 | account.add_authorized_signer (store.persons.item) | ||
| 865 | Result := True | ||
| 866 | back := True | ||
| 867 | else | ||
| 868 | last_error := "Error: Invalid person id" | ||
| 869 | end | ||
| 870 | elseif io.last_string.is_equal ("b") then | ||
| 871 | back := True | ||
| 872 | else | ||
| 873 | last_error := "Error: Not a number" | ||
| 874 | end | ||
| 875 | end | ||
| 876 | end | ||
| 877 | |||
| 878 | edit_account_remove_asigner(account: ACCOUNT): BOOLEAN | ||
| 879 | local | ||
| 880 | back: BOOLEAN | ||
| 881 | do | ||
| 882 | Result := False | ||
| 883 | from | ||
| 884 | list_persons | ||
| 885 | until | ||
| 886 | back | ||
| 887 | loop | ||
| 888 | print_last_error | ||
| 889 | print ("Enter person (authorized signer) id (b ...back): ") | ||
| 890 | io.readline | ||
| 891 | io.last_string.to_lower | ||
| 892 | if io.last_string.is_integer then | ||
| 893 | if store.persons.valid_index (io.last_string.to_integer) then | ||
| 894 | store.persons.go_i_th(io.last_string.to_integer) | ||
| 895 | account.remove_authorized_signer (store.persons.item) | ||
| 896 | Result := True | ||
| 897 | back := True | ||
| 898 | else | ||
| 899 | last_error := "Error: Invalid person id" | ||
| 900 | end | ||
| 901 | elseif io.last_string.is_equal ("b") then | ||
| 902 | back := True | ||
| 903 | else | ||
| 904 | last_error := "Error: Not a number" | ||
| 905 | end | ||
| 906 | end | ||
| 907 | end | ||
| 908 | |||
| 909 | edit_account_deposit(account: ACCOUNT): BOOLEAN | ||
| 910 | local | ||
| 911 | back: BOOLEAN | ||
| 912 | amount: like {ACCOUNT}.balance | ||
| 913 | do | ||
| 914 | Result := False | ||
| 915 | from | ||
| 916 | until | ||
| 917 | back | ||
| 918 | loop | ||
| 919 | print_last_error | ||
| 920 | |||
| 921 | if amount = 0.0 and last_error.is_empty and not back then | ||
| 922 | print ("Enter deposit amount (b ...back): ") | ||
| 923 | io.readline | ||
| 924 | io.last_string.to_lower | ||
| 925 | if io.last_string.is_double and io.last_string.to_double > 0.0 then | ||
| 926 | amount := io.last_string.to_double | ||
| 927 | elseif io.last_string.is_equal("b") then | ||
| 928 | back := True | ||
| 929 | else | ||
| 930 | last_error := "Error: Invalid value" | ||
| 931 | end | ||
| 932 | end | ||
| 933 | |||
| 934 | if last_error.is_empty and not back then | ||
| 935 | list_persons | ||
| 936 | print ("Enter person (authorized signer) id (b ...back): ") | ||
| 937 | io.readline | ||
| 938 | io.last_string.to_lower | ||
| 939 | if io.last_string.is_integer then | ||
| 940 | if store.persons.valid_index (io.last_string.to_integer) then | ||
| 941 | store.persons.go_i_th(io.last_string.to_integer) | ||
| 942 | account.deposit (amount, store.persons.item) | ||
| 943 | Result := True | ||
| 944 | back := True | ||
| 945 | else | ||
| 946 | last_error := "Error: Invalid person id" | ||
| 947 | end | ||
| 948 | elseif io.last_string.is_equal ("b") then | ||
| 949 | back := True | ||
| 950 | else | ||
| 951 | last_error := "Error: Not a number" | ||
| 952 | end | ||
| 953 | end | ||
| 954 | end | ||
| 955 | end | ||
| 956 | |||
| 957 | edit_account_withdraw(account: ACCOUNT): BOOLEAN | ||
| 958 | local | ||
| 959 | back: BOOLEAN | ||
| 960 | amount: like {ACCOUNT}.balance | ||
| 961 | do | ||
| 962 | Result := False | ||
| 963 | from | ||
| 964 | until | ||
| 965 | back | ||
| 966 | loop | ||
| 967 | print_last_error | ||
| 968 | |||
| 969 | if amount = 0.0 and last_error.is_empty and not back then | ||
| 970 | print ("Enter withdraw amount (b ...back): ") | ||
| 971 | io.readline | ||
| 972 | io.last_string.to_lower | ||
| 973 | if io.last_string.is_double and io.last_string.to_double > 0.0 then | ||
| 974 | amount := io.last_string.to_double | ||
| 975 | elseif io.last_string.is_equal("b") then | ||
| 976 | back := True | ||
| 977 | else | ||
| 978 | last_error := "Error: Invalid value" | ||
| 979 | end | ||
| 980 | end | ||
| 981 | |||
| 982 | if last_error.is_empty and not back then | ||
| 983 | list_persons | ||
| 984 | print ("Enter person (authorized signer) id (b ...back): ") | ||
| 985 | io.readline | ||
| 986 | io.last_string.to_lower | ||
| 987 | if io.last_string.is_integer then | ||
| 988 | if store.persons.valid_index (io.last_string.to_integer) then | ||
| 989 | store.persons.go_i_th(io.last_string.to_integer) | ||
| 990 | account.withdraw (amount, store.persons.item) | ||
| 991 | Result := True | ||
| 992 | back := True | ||
| 993 | else | ||
| 994 | last_error := "Error: Invalid person id" | ||
| 995 | end | ||
| 996 | elseif io.last_string.is_equal ("b") then | ||
| 997 | back := True | ||
| 998 | else | ||
| 999 | last_error := "Error: Not a number" | ||
| 1000 | end | ||
| 1001 | end | ||
| 1002 | end | ||
| 1003 | end | ||
| 1004 | |||
| 1005 | edit_account_transfer(account: ACCOUNT): BOOLEAN | ||
| 1006 | local | ||
| 1007 | back: BOOLEAN | ||
| 1008 | amount: like {ACCOUNT}.balance | ||
| 1009 | signer: PERSON | ||
| 1010 | recipient: ACCOUNT | ||
| 1011 | do | ||
| 1012 | Result := False | ||
| 1013 | from | ||
| 1014 | until | ||
| 1015 | back | ||
| 1016 | loop | ||
| 1017 | print_last_error | ||
| 1018 | |||
| 1019 | if amount = 0.0 and last_error.is_empty and not back then | ||
| 1020 | print ("Enter transfer amount (b ...back): ") | ||
| 1021 | io.readline | ||
| 1022 | io.last_string.to_lower | ||
| 1023 | if io.last_string.is_double and io.last_string.to_double > 0.0 then | ||
| 1024 | amount := io.last_string.to_double | ||
| 1025 | elseif io.last_string.is_equal("b") then | ||
| 1026 | back := True | ||
| 1027 | else | ||
| 1028 | last_error := "Error: Invalid value" | ||
| 1029 | end | ||
| 1030 | end | ||
| 1031 | |||
| 1032 | print (signer) | ||
| 1033 | if signer = Void and last_error.is_empty and not back then | ||
| 1034 | list_persons | ||
| 1035 | print ("Enter person (authorized signer) id (b ...back): ") | ||
| 1036 | io.readline | ||
| 1037 | io.last_string.to_lower | ||
| 1038 | if io.last_string.is_integer then | ||
| 1039 | if store.persons.valid_index (io.last_string.to_integer) then | ||
| 1040 | store.persons.go_i_th(io.last_string.to_integer) | ||
| 1041 | signer := store.persons.item | ||
| 1042 | else | ||
| 1043 | last_error := "Error: Invalid person id" | ||
| 1044 | end | ||
| 1045 | elseif io.last_string.is_equal ("b") then | ||
| 1046 | back := True | ||
| 1047 | else | ||
| 1048 | last_error := "Error: Not a number" | ||
| 1049 | end | ||
| 1050 | end | ||
| 1051 | |||
| 1052 | print (recipient) | ||
| 1053 | if recipient = Void and last_error.is_empty and not back then | ||
| 1054 | list_accounts | ||
| 1055 | print ("Enter recipient account id (b ...back): ") | ||
| 1056 | io.readline | ||
| 1057 | io.last_string.to_lower | ||
| 1058 | if io.last_string.is_integer then | ||
| 1059 | if store.accounts.valid_index (io.last_string.to_integer) then | ||
| 1060 | store.accounts.go_i_th(io.last_string.to_integer) | ||
| 1061 | recipient := store.accounts.item | ||
| 1062 | else | ||
| 1063 | last_error := "Error: Invalid account id" | ||
| 1064 | end | ||
| 1065 | elseif io.last_string.is_equal ("b") then | ||
| 1066 | back := True | ||
| 1067 | else | ||
| 1068 | last_error := "Error: Not a number" | ||
| 1069 | end | ||
| 1070 | end | ||
| 1071 | |||
| 1072 | if last_error.is_empty and not back then | ||
| 1073 | list_persons | ||
| 1074 | print ("Enter person (authorized signer) id (b ...back): ") | ||
| 1075 | io.readline | ||
| 1076 | io.last_string.to_lower | ||
| 1077 | if io.last_string.is_integer then | ||
| 1078 | if store.persons.valid_index (io.last_string.to_integer) then | ||
| 1079 | store.persons.go_i_th(io.last_string.to_integer) | ||
| 1080 | account.transfer (amount, signer, recipient, store.persons.item) | ||
| 1081 | Result := True | ||
| 1082 | back := True | ||
| 1083 | else | ||
| 1084 | last_error := "Error: Invalid person id" | ||
| 1085 | end | ||
| 1086 | elseif io.last_string.is_equal ("b") then | ||
| 1087 | back := True | ||
| 1088 | else | ||
| 1089 | last_error := "Error: Not a number" | ||
| 1090 | end | ||
| 1091 | end | ||
| 1092 | end | ||
| 766 | end | 1093 | end |
| 767 | 1094 | ||
| 768 | delete_account | 1095 | delete_account |
| @@ -785,12 +1112,12 @@ feature -- Basic operations | |||
| 785 | last_error := "Account (#" + io.last_string + ") removed successfully" | 1112 | last_error := "Account (#" + io.last_string + ") removed successfully" |
| 786 | back := True | 1113 | back := True |
| 787 | else | 1114 | else |
| 788 | last_error := "Invalid account id" | 1115 | last_error := "Error: Invalid account id" |
| 789 | end | 1116 | end |
| 790 | elseif io.last_string.is_equal ("b") then | 1117 | elseif io.last_string.is_equal ("b") then |
| 791 | back := True | 1118 | back := True |
| 792 | else | 1119 | else |
| 793 | last_error := "Not a number" | 1120 | last_error := "Error: Not a number" |
| 794 | end | 1121 | end |
| 795 | end | 1122 | end |
| 796 | end | 1123 | end |
diff --git a/bank-eiffel/retireeaccount.e b/bank-eiffel/retireeaccount.e index 3db0cd4..24ae004 100644 --- a/bank-eiffel/retireeaccount.e +++ b/bank-eiffel/retireeaccount.e | |||
| @@ -4,12 +4,23 @@ class | |||
| 4 | inherit | 4 | inherit |
| 5 | ACCOUNT | 5 | ACCOUNT |
| 6 | redefine | 6 | redefine |
| 7 | add_authorized_signer, | ||
| 7 | set_default_transfer_minamount | 8 | set_default_transfer_minamount |
| 8 | end | 9 | end |
| 9 | 10 | ||
| 10 | create | 11 | create |
| 11 | make | 12 | make |
| 12 | 13 | ||
| 14 | feature -- Basic operations | ||
| 15 | |||
| 16 | add_authorized_signer (an_authorized_signer: PERSON) | ||
| 17 | do | ||
| 18 | check | ||
| 19 | authorized_signers_only_one: get_authorized_signers.count = 0 | ||
| 20 | end | ||
| 21 | Precursor (an_authorized_signer) | ||
| 22 | end | ||
| 23 | |||
| 13 | feature {NONE} -- Implementation | 24 | feature {NONE} -- Implementation |
| 14 | 25 | ||
| 15 | set_default_transfer_minamount | 26 | set_default_transfer_minamount |
diff --git a/bank-eiffel/studentaccount.e b/bank-eiffel/studentaccount.e index 04a9e31..abbb070 100644 --- a/bank-eiffel/studentaccount.e +++ b/bank-eiffel/studentaccount.e | |||
| @@ -4,12 +4,23 @@ class | |||
| 4 | inherit | 4 | inherit |
| 5 | ACCOUNT | 5 | ACCOUNT |
| 6 | redefine | 6 | redefine |
| 7 | set_default_transfer_minamount | 7 | set_default_transfer_minamount, |
| 8 | add_authorized_signer | ||
| 8 | end | 9 | end |
| 9 | 10 | ||
| 10 | create | 11 | create |
| 11 | make | 12 | make |
| 12 | 13 | ||
| 14 | feature -- Basic operations | ||
| 15 | |||
| 16 | add_authorized_signer (an_authorized_signer: PERSON) | ||
| 17 | do | ||
| 18 | check | ||
| 19 | authorized_signers_only_one: get_authorized_signers.count = 0 | ||
| 20 | end | ||
| 21 | Precursor (an_authorized_signer) | ||
| 22 | end | ||
| 23 | |||
| 13 | feature {NONE} -- Implementation | 24 | feature {NONE} -- Implementation |
| 14 | 25 | ||
| 15 | set_default_transfer_minamount | 26 | set_default_transfer_minamount |
