1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
|
class
BANK
create
run
feature {NONE} -- Implementation
store: BANK_STORE
over: BOOLEAN
last_error: STRING
data_file: RAW_FILE
data_filename: STRING = "bank.data"
fd: FORMAT_DOUBLE
feature {NONE} -- Initialization
run
do
create fd.make(2, 2)
create store.make(100)
store.ranges.account.interest_deposit := [0.01, 0.04]
store.ranges.account.interest_debit := [0.02, 0.1]
store.ranges.account.creditline := [-1000.0, 0.0]
store.ranges.studentaccount.interest_deposit := [0.02, 0.03]
store.ranges.studentaccount.interest_debit := [0.03, 0.06]
store.ranges.studentaccount.creditline := [-300.0, 0.0]
store.ranges.retireeaccount.interest_deposit := [0.02, 0.03]
store.ranges.retireeaccount.interest_debit := [0.03, 0.06]
store.ranges.retireeaccount.creditline := [-300.0, 0.0]
create last_error.make_empty
create data_file.make (data_filename)
if data_file.exists then
data_file.open_read
store ?= store.retrieved (data_file)
data_file.close
end
session
if data_file.is_creatable then
data_file.open_write
store.independent_store (data_file)
data_file.close
end
end
feature -- Basic operations
session
do
from
until
over
loop
main_screen
end
end
print_last_error
do
if not last_error.is_empty then
print (last_error + "%N%N")
last_error := ""
end
end
print_header
do
clear_screen
print ("**************************************%N")
print ("********* BANK of FOOP *********%N")
print ("**************************************%N")
end
clear_screen
do
io.put_character ((0x1B).to_character_8)
io.put_string ("[2J")
io.put_character ((0x1B).to_character_8)
io.put_string ("[H")
end
main_screen
do
print_header
print ("Operations:%N")
print (" r ...list/edit global ranges%N")
print (" p ...list/create/edit/delete persons%N")
print (" a ...list/create/edit/delete accounts%N")
print (" q ...quit%N")
print ("%N")
print_last_error
print ("Enter a command, followed by <return>: ")
io.read_character
io.next_line
inspect io.last_character.lower
when 'r' then
ranges_screen
when 'p' then
persons_screen
when 'a' then
accounts_screen
when 'q' then
over := True
else
last_error := "Error: Unknown command '" + io.last_character.out + "'"
end
print ("%N%N")
end
ranges_screen
local
back: BOOLEAN
do
from
until
back
loop
print_header
print ("Global Ranges:%N")
print (" Account:%N")
print_ranges(store.ranges.account)
print (" Student account:%N")
print_ranges(store.ranges.studentaccount)
print (" Retiree account:%N")
print_ranges(store.ranges.retireeaccount)
print ("%N")
print ("Operations:%N")
print (" a ...edit account ranges%N")
print (" s ...edit student account ranges%N")
print (" r ...edit retiree account ranges%N")
print (" b ...back%N")
print ("%N")
print_last_error
print ("Enter a command, followed by <return>: ")
io.read_character
io.next_line
inspect io.last_character.lower
when 'a' then
edit_ranges("account", store.ranges.account)
when 's' then
edit_ranges("student account", store.ranges.studentaccount)
when 'r' then
edit_ranges("retiree account", store.ranges.retireeaccount)
when 'b' then
back := True
else
last_error := "Error: Unknown command '" + io.last_character.out + "'"
end
print ("%N%N")
end
end
print_ranges(range: like {BANK_STORE}.account_range)
do
print (" - Interest deposit: " + print_range(range.interest_deposit) + "%N")
print (" - Interest debit: " + print_range(range.interest_debit) + "%N")
print (" - Creditline: " + print_range(range.creditline) + "%N")
end
print_range(range: like {BANK_STORE}.range): STRING_8
do
Result := "[" + fd.formatted(range.min) + ", " + fd.formatted(range.max) + "]"
end
edit_ranges(type: STRING_8; range: like {BANK_STORE}.account_range)
do
print ("%N")
print ("Edit " + type + " range:%N")
edit_range("interest depost", range.interest_deposit)
edit_range("interest debit", range.interest_debit)
edit_range("creditline", range.creditline)
end
edit_range(type: STRING_8; range: like {BANK_STORE}.range)
local
back: BOOLEAN
do
from
back := False
until
back
loop
print ("Enter " + type + " minimum [" + fd.formatted(range.min) + "]: ")
io.readline
if io.last_string.is_double then
range.min := io.last_string.to_double
back := True
elseif io.last_string.is_empty then
back := True
else
print ("Invalid value%N")
end
end
from
back := False
until
back
loop
print ("Enter " + type + " maximum [" + fd.formatted(range.max) + "]: ")
io.readline
if io.last_string.is_double then
range.max := io.last_string.to_double
back := True
elseif io.last_string.is_empty then
back := True
else
print ("Invalid value%N")
end
end
end
persons_screen
local
back: BOOLEAN
do
from
until
back
loop
print_header
print ("Operations:%N")
print (" l ...list persons%N")
print (" c ...create person%N")
print (" e ...edit person%N")
print (" d ...delete person%N")
print (" b ...back%N")
print ("%N")
print_last_error
print ("Enter a command, followed by <return>: ")
io.read_character
io.next_line
inspect io.last_character.lower
when 'l' then
list_persons
print ("Press <return> to go back")
io.read_line
when 'c' then
create_persons
when 'e' then
edit_person
when 'd' then
delete_person
when 'b' then
back := True
else
last_error := "Error: Unknown command '" + io.last_character.out + "'"
end
print ("%N%N")
end
end
list_persons
do
print ("%N")
print ("Persons: " + store.persons.count.out + "%N")
from
store.persons.start
until
store.persons.off
loop
print ("#" + store.persons.index.out + " " + store.persons.item.surname + ", " + store.persons.item.firstname)
if attached {RETIREE} store.persons.item then
print (" (RETIREE)")
elseif attached {STUDENT} store.persons.item then
print (" (STUDENT)")
end
print ("%N")
store.persons.forth
end
print ("%N")
end
create_persons
local
back: BOOLEAN
firstname: STRING
surname: STRING
do
from
until
back
loop
print_header
print ("Operations:%N")
print (" p ...create person%N")
print (" s ...create student%N")
print (" r ...create retiree%N")
print (" b ...back%N")
print ("%N")
print_last_error
print ("Enter a command, followed by <return>: ")
io.read_character
io.next_line
inspect io.last_character.lower
when 'p', 's', 'r' then
print ("Enter surname: ")
io.readline
surname := io.last_string.twin
print ("Enter firstname: ")
io.readline
firstname := io.last_string.twin
inspect io.last_character.lower
when 'p' then
store.persons.put(create {PERSON}.make(surname, firstname))
when 's' then
store.persons.put(create {STUDENT}.make(surname, firstname))
when 'r' then
store.persons.put(create {RETIREE}.make(surname, firstname))
else
end
last_error := "Person (#" + store.persons.count.out + ") created successfully"
back := True
when 'b' then
back := True
else
last_error := "Error: Unknown command '" + io.last_character.out + "'"
end
print ("%N%N")
end
rescue
if not (create {EXCEPTIONS}).is_signal then
last_error := "Exception: " + (create {EXCEPTIONS}).tag_name
retry
end
end
edit_person
local
back: BOOLEAN
num: INTEGER
do
list_persons
from
until
back
loop
print_last_error
print ("Enter person id (b ...back): ")
io.readline
io.last_string.to_lower
if io.last_string.is_integer then
num := io.last_string.to_integer
if store.persons.valid_index (num) then
store.persons.go_i_th (num)
print ("Enter surname [" + store.persons.item.surname + "]: ")
io.readline
if not io.last_string.is_empty then
store.persons.item.surname := io.last_string.twin
end
print ("Enter firstname [" + store.persons.item.firstname + "]: ")
io.readline
if not io.last_string.is_empty then
store.persons.item.firstname := io.last_string.twin
end
last_error := "Person (#" + num.out + ") edited successfully"
back := True
else
last_error := "Error: Invalid person id"
end
elseif io.last_string.is_equal ("b") then
back := True
else
last_error := "Error: Not a number"
end
end
end
delete_person
local
back: BOOLEAN
do
list_persons
from
until
back
loop
print_last_error
print ("Enter person id (b ...back): ")
io.readline
io.last_string.to_lower
if io.last_string.is_integer then
if store.persons.valid_index (io.last_string.to_integer) then
store.persons.go_i_th (io.last_string.to_integer)
store.persons.remove
last_error := "Person (#" + io.last_string + ") removed successfully"
back := True
else
last_error := "Error: Invalid person id"
end
elseif io.last_string.is_equal ("b") then
back := True
else
last_error := "Error: Not a number"
end
end
end
accounts_screen
local
back: BOOLEAN
done: BOOLEAN
do
from
until
back
loop
print_header
print ("Operations:%N")
print (" l ...list accounts%N")
print (" c ...create account%N")
print (" e ...edit account%N")
print (" d ...delete account%N")
print (" b ...back%N")
print ("%N")
print_last_error
print ("Enter a command, followed by <return>: ")
io.read_character
io.next_line
inspect io.last_character.lower
when 'l' then
list_accounts
from
done := False
until
back or done
loop
print ("Enter account id for details (b ...back): ")
io.readline
io.last_string.to_lower
if io.last_string.is_integer then
if store.accounts.valid_index (io.last_string.to_integer) then
store.accounts.go_i_th (io.last_string.to_integer)
print ("%N")
print ("Account #" + store.accounts.index.out + ":%N")
list_account_details(store.accounts.item)
print ("Press <return> to go back")
io.read_line
done := True
else
print ("Error: Invalid account id%N%N")
end
elseif io.last_string.is_equal("b") then
done := True
else
print ("Error: Not a number%N%N")
end
end
when 'c' then
create_accounts
when 'e' then
edit_accounts
when 'd' then
delete_account
when 'b' then
back := True
else
last_error := "Error: Unknown command '" + io.last_character.out + "'"
end
print ("%N%N")
end
end
list_accounts
local
account: ACCOUNT
person: PERSON
do
print ("%N")
print ("Accounts: " + store.accounts.count.out + "%N")
from
store.accounts.start
until
store.accounts.off
loop
account := store.accounts.item
account.get_authorized_signers.linear_representation.start
person := account.get_authorized_signers.linear_representation.item
print ("#" + store.accounts.index.out + " " + person.surname + ", " + person.firstname)
if attached {RETIREEACCOUNT} account then
print (" (RETIREE ACCOUNT)")
elseif attached {STUDENTACCOUNT} account then
print (" (STUDENT ACCOUNT)")
end
print ("%N")
store.accounts.forth
end
print ("%N")
end
list_account_details(account: ACCOUNT)
local
person: PERSON
range: like {BANK_STORE}.account_range
do
range := store.ranges.account
if attached {RETIREEACCOUNT} account then
range := store.ranges.retireeaccount
elseif attached {STUDENTACCOUNT} account then
range := store.ranges.studentaccount
end
print (" - Balance: " + fd.formatted(account.balance) + "%N")
print (" - Interest deposit: " + fd.formatted(account.interest_deposit) + " " + print_range(range.interest_deposit) + "%N")
print (" - Interest debit: " + fd.formatted(account.interest_debit) + " " + print_range(range.interest_debit) +"%N")
print (" - Creditline: " + fd.formatted(account.creditline) + " " + print_range(range.creditline) +"%N")
print (" - Minimum transfer amount: " + fd.formatted(account.transfer_minamount) +"%N")
print (" - Authorized signers:%N")
from
account.get_authorized_signers.linear_representation.start
until
account.get_authorized_signers.linear_representation.off
loop
person := account.get_authorized_signers.linear_representation.item
print (" - #" + account.get_authorized_signers.linear_representation.index.out + " " + person.surname + ", " + person.firstname)
if attached {RETIREE} person then
print (" (RETIREE)")
elseif attached {STUDENT} person then
print (" (STUDENT)")
end
print ("%N")
account.get_authorized_signers.linear_representation.forth
end
print (" - Type: ")
if attached {RETIREEACCOUNT} account then
print ("Retiree account")
elseif attached {STUDENTACCOUNT} account then
print ("Student account")
else
print ("Account")
end
print ("%N%N")
end
create_accounts
local
back: BOOLEAN
do
from
until
back
loop
print_header
print ("Operations:%N")
print (" a ...create account%N")
print (" s ...create student account%N")
print (" r ...create retiree account%N")
print (" b ...back%N")
print ("%N")
print_last_error
print ("Enter a command, followed by <return>: ")
io.read_character
io.next_line
inspect io.last_character.lower
when 'a' then
back := create_account('a', store.ranges.account)
when 's' then
back := create_account('s', store.ranges.studentaccount)
when 'r' then
back := create_account('r', store.ranges.retireeaccount)
when 'b' then
back := True
else
last_error := "Error: Unknown command '" + io.last_character.out + "'"
end
print ("%N%N")
end
rescue
if not (create {EXCEPTIONS}).is_signal then
last_error := "Exception: " + (create {EXCEPTIONS}).tag_name
retry
end
end
create_account(type: CHARACTER; range: like {BANK_STORE}.account_range): BOOLEAN
local
back: BOOLEAN
next: BOOLEAN
interest_deposit: like {ACCOUNT}.interest_deposit
interest_debit: like {ACCOUNT}.interest_debit
creditline: like {ACCOUNT}.creditline
do
Result := false
interest_deposit := (range.interest_deposit.min + range.interest_deposit.max) / 2
interest_debit := (range.interest_debit.min + range.interest_debit.max) / 2
creditline := (range.creditline.min + range.creditline.max) / 2
print_last_error
from
next := False
list_persons
until
back or next
loop
print ("Enter person (authorized signer) id (b ...back): ")
io.readline
io.last_string.to_lower
if io.last_string.is_integer then
if store.persons.valid_index (io.last_string.to_integer) then
store.persons.go_i_th (io.last_string.to_integer)
next := True
else
print ("Error: Invalid person id%N%N")
end
elseif io.last_string.is_equal ("b") then
back := True
else
print ("Error: Not a number%N%N")
end
end
from
next := False
until
back or next
loop
print ("Enter interest deposit " + print_range(range.interest_deposit) + " [" + fd.formatted(interest_deposit) + "] (b ...back): ")
io.readline
io.last_string.to_lower
if io.last_string.is_empty then
next := True
elseif io.last_string.is_double then
interest_deposit := io.last_string.to_double
next := True
elseif io.last_string.is_equal ("b") then
back := True
else
print ("Error: Invalid interest deposit number%N%N")
end
end
from
next := False
until
back or next
loop
print ("Enter interest debit " + print_range(range.interest_debit) + " [" + fd.formatted(interest_debit) + "] (b ...back):")
io.readline
io.last_string.to_lower
if io.last_string.is_empty then
next := True
elseif io.last_string.is_double then
interest_debit := io.last_string.to_double
next := True
elseif io.last_string.is_equal ("b") then
back := True
else
print ("Error: Invalid interest debit number%N%N")
end
end
from
next := False
until
back or next
loop
print ("Enter creditline " + print_range(range.creditline) + " [" + fd.formatted(creditline) + "] (b ...back): ")
io.readline
io.last_string.to_lower
if io.last_string.is_empty then
next := True
elseif io.last_string.is_double then
creditline := io.last_string.to_double
next := True
elseif io.last_string.is_equal ("b") then
back := True
else
print ("Error: Invalid creditline number%N%N")
end
end
if not back then
inspect type
when 'a' then
store.accounts.put(create {ACCOUNT}.make(store.persons.item,
interest_deposit, interest_debit, creditline,
range.interest_deposit, range.interest_debit, range.creditline))
when 's' then
store.accounts.put(create {STUDENTACCOUNT}.make(store.persons.item,
interest_deposit, interest_debit, creditline,
range.interest_deposit, range.interest_debit, range.creditline))
when 'r' then
store.accounts.put(create {RETIREEACCOUNT}.make(store.persons.item,
interest_deposit, interest_debit, creditline,
range.interest_deposit, range.interest_debit, range.creditline))
else
end
last_error := "Account (#" + store.accounts.count.out + ") created successfully"
Result := true
back := True
end
end
edit_accounts
local
back: BOOLEAN
do
list_accounts
from
until
back
loop
print_last_error
print ("Enter account id (b ...back): ")
io.readline
io.last_string.to_lower
if io.last_string.is_integer then
if store.accounts.valid_index (io.last_string.to_integer) then
store.accounts.go_i_th (io.last_string.to_integer)
edit_account(store.accounts.index, store.accounts.item)
back := True
else
last_error := "Error: Invalid account id"
end
elseif io.last_string.is_equal ("b") then
back := True
else
last_error := "Error: Not a number"
end
end
end
edit_account(index: INTEGER; account: ACCOUNT)
local
back: BOOLEAN
do
from
until
back
loop
print_header
print ("Edit account #" + index.out + ":%N")
list_account_details (account)
print ("Operations:%N")
print (" 1 ...edit interest deposit%N")
print (" 2 ...edit interest debit%N")
print (" 3 ...edit creditline%N")
print (" 4 ...edit minimum transfer amount%N")
print (" 5 ...add authorized signer%N")
print (" 6 ...remove authorized signer%N")
print (" 7 ...deposit%N")
print (" 8 ...withdraw%N")
print (" 9 ...transfer%N")
print (" 0 ...advance%N")
print (" b ...back%N")
print ("%N")
print_last_error
print ("Enter a command, followed by <return>: ")
io.read_character
io.next_line
inspect io.last_character.lower
when '1' then
account.interest_deposit := edit_account_detail_double("interest deposit", account.interest_deposit)
last_error := "Interest deposit changed successfully"
when '2' then
account.interest_debit := edit_account_detail_double("interest debit", account.interest_debit)
last_error := "Interest debit changed successfully"
when '3' then
account.creditline := edit_account_detail_double("creditline", account.creditline)
last_error := "Creditline changed successfully"
when '4' then
account.transfer_minamount := edit_account_detail_double("transfer miniumum amount", account.transfer_minamount)
last_error := "Transfer minimum amount changed successfully"
when '5' then
if edit_account_add_asigner (account) then
last_error := "Authorized signer added successfully"
end
when '6' then
if edit_account_remove_asigner (account) then
last_error := "Authorized signer removed successfully"
end
when '7' then
if edit_account_deposit (account) then
last_error := "Deposit successfully"
end
when '8' then
if edit_account_withdraw (account) then
last_error := "Widthdraw successfully"
end
when '9' then
if edit_account_transfer (account) then
last_error := "Transfer successfully"
end
when '0' then
account.advance
last_error := "Account advanced successfully"
when 'b' then
back := True
else
last_error := "Error: Unknown command '" + io.last_character.out + "'"
end
print ("%N%N")
end
rescue
if not (create {EXCEPTIONS}).is_signal then
last_error := "Exception: " + (create {EXCEPTIONS}).tag_name
retry
end
end
edit_account_detail_double(type: STRING_8; val: REAL_64): REAL_64
local
back: BOOLEAN
do
Result := val
from
until
back
loop
print ("Enter " + type + " [" + fd.formatted(val) + "]: ")
io.readline
if io.last_string.is_double then
Result := io.last_string.to_double
back := True
elseif io.last_string.is_empty then
back := True
else
print ("Error: Invalid value%N")
end
end
end
edit_account_add_asigner(account: ACCOUNT): BOOLEAN
local
back: BOOLEAN
do
Result := False
from
list_persons
until
back
loop
print_last_error
print ("Enter person (authorized signer) id (b ...back): ")
io.readline
io.last_string.to_lower
if io.last_string.is_integer then
if store.persons.valid_index (io.last_string.to_integer) then
store.persons.go_i_th(io.last_string.to_integer)
account.add_authorized_signer (store.persons.item)
Result := True
back := True
else
last_error := "Error: Invalid person id"
end
elseif io.last_string.is_equal ("b") then
back := True
else
last_error := "Error: Not a number"
end
end
end
edit_account_remove_asigner(account: ACCOUNT): BOOLEAN
local
back: BOOLEAN
do
Result := False
from
list_persons
until
back
loop
print_last_error
print ("Enter person (authorized signer) id (b ...back): ")
io.readline
io.last_string.to_lower
if io.last_string.is_integer then
if store.persons.valid_index (io.last_string.to_integer) then
store.persons.go_i_th(io.last_string.to_integer)
account.remove_authorized_signer (store.persons.item)
Result := True
back := True
else
last_error := "Error: Invalid person id"
end
elseif io.last_string.is_equal ("b") then
back := True
else
last_error := "Error: Not a number"
end
end
end
edit_account_deposit(account: ACCOUNT): BOOLEAN
local
back: BOOLEAN
amount: like {ACCOUNT}.balance
do
Result := False
from
until
back
loop
print_last_error
if amount = 0.0 and last_error.is_empty and not back then
print ("Enter deposit amount (b ...back): ")
io.readline
io.last_string.to_lower
if io.last_string.is_double and io.last_string.to_double > 0.0 then
amount := io.last_string.to_double
elseif io.last_string.is_equal("b") then
back := True
else
last_error := "Error: Invalid value"
end
end
if last_error.is_empty and not back then
list_persons
print ("Enter person (authorized signer) id (b ...back): ")
io.readline
io.last_string.to_lower
if io.last_string.is_integer then
if store.persons.valid_index (io.last_string.to_integer) then
store.persons.go_i_th(io.last_string.to_integer)
account.deposit (amount, store.persons.item)
Result := True
back := True
else
last_error := "Error: Invalid person id"
end
elseif io.last_string.is_equal ("b") then
back := True
else
last_error := "Error: Not a number"
end
end
end
end
edit_account_withdraw(account: ACCOUNT): BOOLEAN
local
back: BOOLEAN
amount: like {ACCOUNT}.balance
do
Result := False
from
until
back
loop
print_last_error
if amount = 0.0 and last_error.is_empty and not back then
print ("Enter withdraw amount (b ...back): ")
io.readline
io.last_string.to_lower
if io.last_string.is_double and io.last_string.to_double > 0.0 then
amount := io.last_string.to_double
elseif io.last_string.is_equal("b") then
back := True
else
last_error := "Error: Invalid value"
end
end
if last_error.is_empty and not back then
list_persons
print ("Enter person (authorized signer) id (b ...back): ")
io.readline
io.last_string.to_lower
if io.last_string.is_integer then
if store.persons.valid_index (io.last_string.to_integer) then
store.persons.go_i_th(io.last_string.to_integer)
account.withdraw (amount, store.persons.item)
Result := True
back := True
else
last_error := "Error: Invalid person id"
end
elseif io.last_string.is_equal ("b") then
back := True
else
last_error := "Error: Not a number"
end
end
end
end
edit_account_transfer(account: ACCOUNT): BOOLEAN
local
back: BOOLEAN
amount: like {ACCOUNT}.balance
signer: PERSON
recipient: ACCOUNT
do
Result := False
from
until
back
loop
print_last_error
if amount = 0.0 and last_error.is_empty and not back then
print ("Enter transfer amount (b ...back): ")
io.readline
io.last_string.to_lower
if io.last_string.is_double and io.last_string.to_double > 0.0 then
amount := io.last_string.to_double
elseif io.last_string.is_equal("b") then
back := True
else
last_error := "Error: Invalid value"
end
end
print (signer)
if signer = Void and last_error.is_empty and not back then
list_persons
print ("Enter person (authorized signer) id (b ...back): ")
io.readline
io.last_string.to_lower
if io.last_string.is_integer then
if store.persons.valid_index (io.last_string.to_integer) then
store.persons.go_i_th(io.last_string.to_integer)
signer := store.persons.item
else
last_error := "Error: Invalid person id"
end
elseif io.last_string.is_equal ("b") then
back := True
else
last_error := "Error: Not a number"
end
end
print (recipient)
if recipient = Void and last_error.is_empty and not back then
list_accounts
print ("Enter recipient account id (b ...back): ")
io.readline
io.last_string.to_lower
if io.last_string.is_integer then
if store.accounts.valid_index (io.last_string.to_integer) then
store.accounts.go_i_th(io.last_string.to_integer)
recipient := store.accounts.item
else
last_error := "Error: Invalid account id"
end
elseif io.last_string.is_equal ("b") then
back := True
else
last_error := "Error: Not a number"
end
end
if last_error.is_empty and not back then
list_persons
print ("Enter person (authorized signer) id (b ...back): ")
io.readline
io.last_string.to_lower
if io.last_string.is_integer then
if store.persons.valid_index (io.last_string.to_integer) then
store.persons.go_i_th(io.last_string.to_integer)
account.transfer (amount, signer, recipient, store.persons.item)
Result := True
back := True
else
last_error := "Error: Invalid person id"
end
elseif io.last_string.is_equal ("b") then
back := True
else
last_error := "Error: Not a number"
end
end
end
end
delete_account
local
back: BOOLEAN
do
list_accounts
from
until
back
loop
print_last_error
print ("Enter account id (b ...back): ")
io.readline
io.last_string.to_lower
if io.last_string.is_integer then
if store.accounts.valid_index (io.last_string.to_integer) then
store.accounts.go_i_th (io.last_string.to_integer)
store.accounts.remove
last_error := "Account (#" + io.last_string + ") removed successfully"
back := True
else
last_error := "Error: Invalid account id"
end
elseif io.last_string.is_equal ("b") then
back := True
else
last_error := "Error: Not a number"
end
end
end
end
|