#include "OutputProcessor.h"

// Author: Steve Talbot

OutputProcessor:: OutputProcessor( Data* data_ ){

	_data = data_;

	_PFP = new prompt_for_pin_1();

	_IIM = new incorrect_id_msg_1();

	_IPM = new incorrect_pin_msg_1();

	_TMAM = new too_many_attempts_msg_1();

	_DM = new display_menu_1();

	_DAM = new deactivate_msg_1();

	_MW = new make_withdraw_1();

	_PE = new penalty_1();

	_MD = new make_deposit_1();

	_DB = new display_balance_1();

	_BMBM = new below_min_balance_msg_1();

	_AM = new activate_msg_1();

	_IAM = new inactive_account_msg_1();

}

OutputProcessor:: ~OutputProcessor(){

	if( _PFP != NULL ) delete _PFP;

	if( _IIM != NULL ) delete _IIM;

	if( _IPM != NULL ) delete _IPM;

	if( _TMAM != NULL ) delete _TMAM;

	if( _DM != NULL ) delete _DM;

	if( _DAM != NULL ) delete _DAM;

	if( _MW != NULL ) delete _MW;

	if( _PE != NULL ) delete _PE;

	if( _MD != NULL ) delete _MD;

	if( _DB != NULL ) delete _DB;

	if( _BMBM != NULL ) delete _BMBM;

	if( _AM != NULL ) delete _AM;

	if( _IAM != NULL ) delete _IAM;

}

void OutputProcessor:: removeCurrentConfiguration(){

	if( _PFP != NULL ) delete _PFP;

	if( _IIM != NULL ) delete _IIM;

	if( _IPM != NULL ) delete _IPM;

	if( _TMAM != NULL ) delete _TMAM;

	if( _DM != NULL ) delete _DM;

	if( _DAM != NULL ) delete _DAM;

	if( _MW != NULL ) delete _MW;

	if( _PE != NULL ) delete _PE;

	if( _MD != NULL ) delete _MD;

	if( _DB != NULL ) delete _DB;

	if( _BMBM != NULL ) delete _BMBM;

	if( _AM != NULL ) delete _AM;

	if( _IAM != NULL ) delete _IAM;

}

bool OutputProcessor:: prompt_for_pin(){

	// invoked by “Idle:: correct_login()” ..

	return _PFP->prompt_for_pin( _data );

}

bool OutputProcessor:: incorrect_id_msg(){

	// invoked by “Idle:: incorrect_login()” ..

	return _IIM->incorrect_id_msg( _data );

}

bool OutputProcessor:: incorrect_pin_msg(){

	// invoked by
	// “CheckPin:: attempts_remain()”,
	// “Ready:: incorrect_pin()” ..
	// “Overdrawn:: incorrect_pin()” ..
	// “Inactive:: incorrect_pin()” ..

	return _IPM->incorrect_pin_msg( _data );

}

bool OutputProcessor:: too_many_attempts_msg(){

	// invoked by “CheckPin:: too_many_attempts()” ..

	return _TMAM->too_many_attempts_msg( _data );

}

bool OutputProcessor:: display_menu(){

	// invoked by
	// “CheckPin:: above_min_balance()”,
	// “CheckPin:: below_min_balance()”..

	return _DM->display_menu( _data );

}

bool OutputProcessor:: deactivate_msg(){

	// invoked by
	// “CheckPin:: inactive()”,
	// “Ready:: correct_pin()”
	// “Overdrawn:: correct_pin()” ..

	return _DAM->deactivate_msg( _data );

}

bool OutputProcessor:: make_withdraw(){

	// invoked by
	// “Ready:: diff_less_than_min_balance()”,
	// “Ready:: diff_more_or_equal_to_min_balance()” ..

	return _MW-> make_withdraw( _data );

}

bool OutputProcessor:: penalty(){

	// invoked by “Ready:: diff_less_than_min_balance()” ..

	return _PE-> penalty( _data );

}

bool OutputProcessor:: make_deposit(){

	// invoked by “Ready:: deposit()”,
	// “Overdrawn:: sum_more_or_equal_to_min_balance()”,
	// “Overdrawn:: sum_less_than_min_balance()” ..

	return _MD->make_deposit( _data );


}

bool OutputProcessor:: display_balance(){

	// invoked by “Ready:: balance()”,
	// “Overdrawn:: balance()” ..

	return _DB->display_balance( _data );

}

bool OutputProcessor:: below_min_balance_msg(){

	// invoked by “Overdrawn:: withdraw()” ..

	return _BMBM->below_min_balance_msg( _data );

}

bool OutputProcessor:: activate_msg(){

	// invoked by “Inactive:: above_min_balance()”,
	// “Inactive:: below_min_balance()” ..

	return _AM->activate_msg( _data );

}

bool OutputProcessor:: inactive_account_msg(){

	// invoked by Inactive:: withdraw()”,
	// “Inactive:: deposit()“,
	// “Inactive:: balance() ..

	return _IAM->inactive_account_msg( _data );

}


/*
 * SETTERS ..
 */

void OutputProcessor:: setPromptForPinA( prompt_for_pin_a* PFP_ ){

	if( _PFP != NULL ) delete _PFP;

	_PFP = PFP_;

}

void OutputProcessor:: setIncorrectIdMsgA( incorrect_id_msg_a* IIM_ ){

	if( _IIM != NULL ) delete _IIM;

	_IIM = IIM_;

}

void OutputProcessor:: setIncorrectPinMsgA( incorrect_pin_msg_a* IPM_ ){

	if( _IPM != NULL ) delete _IPM;

	_IPM = IPM_;

}

void OutputProcessor:: setTooManyAttemptsMsgA( too_many_attempts_msg_a* TMAM_ ){

	if( _TMAM != NULL ) delete _TMAM;

	_TMAM = TMAM_;

}

void OutputProcessor:: setDisplayMenuA( display_menu_a* DM_ ){

	if( _DM != NULL ) delete _DM;

	_DM = DM_;

}

void OutputProcessor:: setDeactivateMsgA( deactivate_msg_a* DAM_ ){

	if( _DAM != NULL ) delete _DAM;

	_DAM = DAM_;

}

void OutputProcessor:: setMakeWithdrawMsgA( make_withdraw_a* MW_ ){

	if( _MW != NULL ) delete _MW;

	_MW = MW_;

}

void OutputProcessor:: setPenaltyA( penalty_a* PE_ ){

	if( _PE != NULL ) delete _PE;

	_PE = PE_;

}

void OutputProcessor:: setMakeDepositA( make_deposit_a* MD_ ){

	if( _MD != NULL ) delete _MD;

	_MD = MD_;

}

void OutputProcessor:: setDisplayBalanceA( display_balance_a* DB_ ){

	if( _DB != NULL ) delete _DB;

	_DB = DB_;

}

void OutputProcessor:: setBelowMinBalanceMsgA( below_min_balance_msg_a* BMBM_ ){

	if( _BMBM != NULL ) delete _BMBM;

	_BMBM = BMBM_;

}

void OutputProcessor:: setActivateMsgA( activate_msg_a* AM_ ){

	if( _AM != NULL ) delete _AM;

	_AM = AM_;

}

void OutputProcessor:: setInactiveAccountMsgA( inactive_account_msg_a* IAM_ ){

	if( _IAM != NULL ) delete _IAM;

	_IAM = IAM_;

}

/*
 * GETTERS ..
 */

prompt_for_pin_a* OutputProcessor:: getPromptForPinA(){

	return _PFP;

}

incorrect_id_msg_a* OutputProcessor:: getIncorrectIdMsgA(){

	return _IIM;

}

incorrect_pin_msg_a* OutputProcessor:: getIncorrectPinMsgA(){

	return _IPM;

}

too_many_attempts_msg_a* OutputProcessor:: getTooManyAttemptsMsgA(){

	return _TMAM;

}

display_menu_a* OutputProcessor:: getDisplayMenuA(){

	return _DM;

}

deactivate_msg_a* OutputProcessor:: getDeactivateMsgA(){

	return _DAM;

}

make_withdraw_a* OutputProcessor:: getMakeWithdawA(){

	return _MW;

}

penalty_a* OutputProcessor:: getPenaltyA(){

	return _PE;

}

make_deposit_a* OutputProcessor:: getMakeDepositA(){

	return _MD;

}

display_balance_a* OutputProcessor:: getDisplayBalanceA(){

	return _DB;

}

below_min_balance_msg_a* OutputProcessor:: getBelowMinBalanceMsgA(){

	return _BMBM;

}

activate_msg_a* OutputProcessor:: getActivateMsgA(){

	return _AM;

}

inactive_account_msg_a* OutputProcessor:: getInactiveAccountMsgA(){

	return _IAM;

}

void OutputProcessor:: resetNumberOfAttempts(){

	_data->setAttempts( 0 );

}
