#include "deactivate_1.h"

// Author: Steve Talbot

deactivate_1:: deactivate_1(){
}

deactivate_1:: ~deactivate_1(){
}

bool deactivate_1:: deactivate( Data* data_, MDA_EFSM* M_ ){

	// prompt for pin ..

	cout << (* data_->getMessage( data_->_messageIds->PIN_PROMPT ) ) <<": ";
	char input[1000];
	cin.getline( input, 1000 );
	string inputString = input;

	// need to strip off the "\r" or "\n" at the end of the input ..
	if( ( inputString[( inputString.size() - 1 )] == '\n' ) ||
		( inputString[( inputString.size() - 1 )] == '\r' ) )
		inputString = inputString.substr( 0, ( inputString.size() - 1 ) );


	// check pin validity ..

	bool isPinCorrect = false;

	int id = data_->getCurrentAccountInfo()->getID();


	if( data_->isPinCorrect( strToInt( inputString ), id ) == true )
		isPinCorrect = true;

	M_->deactivate( isPinCorrect );

	return isPinCorrect;


}
