-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForeignBank.java
More file actions
112 lines (46 loc) · 2.2 KB
/
ForeignBank.java
File metadata and controls
112 lines (46 loc) · 2.2 KB
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
package eWAGI_Firms;
import java.util.ArrayList;
import repast.simphony.context.Context;
import repast.simphony.engine.schedule.ScheduledMethod;
import repast.simphony.util.ContextUtils;
public class ForeignBank{
int ID;
ArrayList<PaymentAccount> paymentAccountList;
ForeignBank(int ID){
this.ID = ID;
paymentAccountList = new ArrayList<PaymentAccount>();
}
@ScheduledMethod (start = 1, interval = 1, priority = 65)
public void executeTransactions1() {
executePendingTransactions();
}
@ScheduledMethod (start = 1, interval = 1, priority = 21)
public void executeTransactions2() {
executePendingTransactions();
}
public void executePendingTransactions() {
Bank aBank;
for(int i=0; i < paymentAccountList.size(); i++) {
for(int j=0; j < paymentAccountList.get(i).pendingOutgoingTransactionsList.size();j++) {
Context context = ContextUtils.getContext(this);
Iterable<Bank> allBanks = context.getObjects(Bank.class);
for(Bank obj : allBanks) {
if(obj.ID == paymentAccountList.get(i).pendingOutgoingTransactionsList.get(j).receiverBankID) {
aBank = (Bank) obj;
for(int k=0; k < aBank.paymentAccountList.size(); k++) {
if(aBank.paymentAccountList.get(k).holderID==paymentAccountList.get(i).pendingOutgoingTransactionsList.get(j).receiverID) {
paymentAccountList.get(i).accountBalance -= paymentAccountList.get(i).pendingOutgoingTransactionsList.get(j).amount;
aBank.paymentAccountList.get(k).accountBalance += paymentAccountList.get(i).pendingOutgoingTransactionsList.get(j).amount;
aBank.paymentAccountList.get(k).receivedTransactionsList.add(paymentAccountList.get(i).pendingOutgoingTransactionsList.get(j));
paymentAccountList.get(i).pendingOutgoingTransactionsList.remove(j);
j--;
break;
}
}
break;
}
}
}
}
}
}