#include "deposit_2.h"

// Author: Steve Talbot

deposit_2:: deposit_2(){
}

deposit_2:: ~deposit_2(){

}

bool deposit_2:: deposit( Data* data_, MDA_EFSM* M_ ){

	bool isLessThanMinBalance = true;

	// calculate the “deposit” operation ..

	int currentBalance = data_->getCurrentAccountInfo()->getB();
	int depositAmount = data_->getD();

	int result = ( currentBalance + depositAmount );

	// check whether this is an “overdraw” ..

	int minBalance = data_->getMinBalance();

	if( result >= minBalance )
		isLessThanMinBalance = false;

	// "alternate" configuration ..

	AccountInfo* accountInfo = data_->getCurrentAccountInfo();

	int id = accountInfo->getID();

	cout << "id: " << id << ", min balance: " << minBalance << ", deposit: " << depositAmount << ", new balance: " << result << endl;

	M_->deposit( isLessThanMinBalance );

	// deposit always allowed, so this is always true ..
	return true;


}
