-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbankloan.fool
More file actions
28 lines (22 loc) · 828 Bytes
/
Copy pathbankloan.fool
File metadata and controls
28 lines (22 loc) · 828 Bytes
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
let
class Account (money:int) {
fun getMon:int () money;
}
class TradingAcc extends Account (invested:int) {
fun getInv:int () invested;
}
class BankLoan (loan: Account) {
fun getLoan:Account () loan;
fun openLoan:Account (m:TradingAcc) if ((m.getMon()+m.getInv())>=30000)
then {new Account(loan.getMon())}
else {null};
}
class MyBankLoan extends BankLoan (loan: TradingAcc) {
fun openLoan:TradingAcc (l:Account) if (l.getMon()>=20000)
then {new TradingAcc(loan.getMon(),loan.getInv())}
else {null};
}
var bl:BankLoan = new MyBankLoan(new TradingAcc(50000,40000));
var myTradingAcc:TradingAcc = new TradingAcc(20000,5000);
var myLoan:Account = bl.openLoan(myTradingAcc);
in print(if (myLoan==null) then {0} else {myLoan.getMon()});