#include "withdraw_1.h"

// Author: Steve Talbot

withdraw_1:: withdraw_1(){
}

withdraw_1:: ~withdraw_1(){
}

bool withdraw_1:: withdraw( Data* data_, MDA_EFSM* M_ ){

	bool isLessThanMinBalance = false;

	// calculate the “withdraw” operation ..

	int currentBalance = data_->getCurrentAccountInfo()->getB();
	int withdrawAmount = data_->getW();

	int result = ( currentBalance - withdrawAmount );

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

	int minBalance = data_->getMinBalance();

	if( result < minBalance )
		isLessThanMinBalance = true;

	M_->withdraw( isLessThanMinBalance );

	return isLessThanMinBalance;


}
