BankCustomer - ellenvoegtli/simcity GitHub Wiki

###Data: String name; BankManager bm; Banker b; int bankernumber; teller t; int tellernumber; double myaccountnumber;

//customer should know how much money he has beforehand
double bankbalance;
double mymoney;

//will be used for all transactions, loan requests, etc
int amount;

BankCustomerTransactionState{ wantToDeposit, wantToWithdraw, wantNewAccount, wantLoan}

    BankCustomerState{ none,waitingInBank,atTeller, atBanker, assignedTeller, assignedBanker, goingToTeller, goingToBanker, talking, leaving, done}

###Messages: //messages that would prompt going to the bank

msgNeedLoan(){
	BankCustomerTransactionState =wantLoan;
}

msgWantNewAccount(){
	BankCustomerTransactionState =wantNewAccount;
}

msgWantToDeposit(){
	BankCustomerTransactionState =wantToDeposit;
}

msgWantToWithdraw(){
	BankCustomerTransactionState =wantToWithdraw;
}

msgGoToTeller(teller te, int tn){
	t=te;
	tellernumber=tn;
	BankCustomerState =assignedTeller;
}
msgGoToBanker(int bn, Banker bk ){
	b=bk;
	bankernumber=bn;
	BankCustomerState =assignedBanker;
}
msgAtTeller(){
	BankCustomerState =atTeller;
}

msgAtBanker(){
	BankCustomerState =atBanker;
}

msgRequestComplete(int change, int balance){
	mymoney += change;
	bankbalance=balance;
	BankCustomerState=done;
	
}
msgAccountCreated(double newaccount){
	myaccountnumber=newaccount;
	bankbalance=amount;
	mymoney-=amount;
	BankCustomerState=done;
}

msgLoanApproved(int loanamount){
	 mymoney+=amount;
	BankCustomerState=done;
	
}
msgLoanDenied(int loanamount){
	BankCustomerState=done;
	
}

###Scheduler: If(BankCustomerState=none & BankCustomerTransactionState = wantToDeposit){ BankCustomerState=waitingInBank; tellBankManagerDeposit(); }

If(BankCustomerState=none & BankCustomerTransactionState = wantToWithdraw){
	BankCustomerState=waitingInBank;
	tellBankManagerWithdraw();
}

If(BankCustomerState=assignedTeller){
	BankCustomerState=goingToTeller;
	doGoToTeller();
}

If(BankCustomerState=assignedBanker){
	BankCustomerState=goingToBanker;
	doGoToBanker();
}

If(BankCustomerState=atTeller){
	BankCustomerState=talking;
	
	if(BankCustomerTransactionState=wantToWithDraw){
	withdrawTeller(amount);
	}

	if(BankCustomerTransactionState=wantToDeposit){
	depositTeller(amount);
	}
}

If(BankCustomerState=atBanker){
	BankCustomerState=talking;
	
	if(BankCustomerTransactionState=wantNewAccount){
		requestNewAccount(amount);
	}

	if(BankCustomerTransactionState=wantLoan){
		requestLoan(amount);
	}
}



If(BankCustomerState=done){
	BankCustomerState=leaving;
	doLeaveBank();
}

###Actions: tellBankManagerDeposit(){

	bm.msgIWantToDeposit(this);


}

tellBankManagerWithdraw(){

	bm.msgIWantToWithDraw(this);

}

withdrawTeller( int n){
	t.msgIWantToWithdraw(this, n);
	
}

depositTeller( int n){
	t.msgIWantToDeposit(this, n);
	
}

requestLoan(int n){
	b.msgIWantALoan(this, amount);
}

requestNewAccount(int n){
	b.msgIWantNewAccount(this, amount);

}