#include "Ready.h"

// Author: Steve Talbot

Ready:: Ready(){

}

Ready:: ~Ready(){
}

bool Ready:: logout( int& nextStateId_ ){

	// save “currentAccountInfo” to file (persistence) ..

	nextStateId_ = _stateIds->IDLE;

	return true;

}

bool Ready:: withdraw( bool isLessThanMinBalance_, int& nextStateId_ ){

	// “isLessThanMinBalance_” passed in from the Account..

	if( isLessThanMinBalance_ == true ) {

		return diff_less_than_min_balance( nextStateId_ );

	} else {

		return diff_more_or_equal_to_min_balance();

	}

}

bool Ready:: deposit( bool isLessThanMinBalance_, int& nextStateId_ ){

	// “isLessThanMinBalance_” passed in from Account (not used, interface only)..
	// (i.e.: only a “withdraw” transitions between “Ready” to “Overdrawn” states)

	nextStateId_ = _stateIds->READY;

	bool result = getOutputProcessor()->make_deposit();

	getOutputProcessor()->display_menu();

	return result;

}

bool Ready:: balance(){

	bool result = getOutputProcessor()->display_balance();

	getOutputProcessor()->display_menu();

	return result;

}

bool Ready:: deactivate( bool isCorrectPin_, int& nextStateId_ ){

	// “hasCorrectPin_” passed in from the Account..

	bool result = false;

	if ( isCorrectPin_ == true ) {

		result = correct_pin( nextStateId_ );

	} else {

		// no limit on number attempts to deactivate ..

		result = incorrect_pin();

	}

	return result;

}

bool Ready:: correct_pin( int& nextStateId_ ){

	nextStateId_ = _stateIds->INACTIVE;

	bool result = getOutputProcessor()->deactivate_msg();

	getOutputProcessor()->display_menu();

	return result;

}

bool Ready:: incorrect_pin(){

	// no limit on number attempts to deactivate ..

	bool result = getOutputProcessor()->incorrect_pin_msg();

	getOutputProcessor()->display_menu();

	return result;

}

bool Ready:: diff_less_than_min_balance( int& nextStateId_ ){

	nextStateId_ = _stateIds->OVERDRAWN;

	bool isMakeWithdraw = getOutputProcessor()->make_withdraw();

	bool isPenalty = getOutputProcessor()->penalty();

	getOutputProcessor()->display_menu();

	if ( isMakeWithdraw && isPenalty )
		return true;
	else
		return false;

}

bool Ready:: diff_more_or_equal_to_min_balance(){

	bool result = getOutputProcessor()->make_withdraw();

	getOutputProcessor()->display_menu();

	return result;

}

// these are only necessary if the parent class defines these
// methods are "abstract" (i.e.: pure virtual) methods ..

//bool Ready:: correct_login( int& nextStateId_ ){/*empty implementation*/ return false; }							// Idle();
//bool Ready:: incorrect_login(){/*empty implementation*/ return false; }											// Idle();

//bool Ready:: correct_pin( bool isAboveMinBalance_, int& nextStateId_ ){/*empty implementation*/ return false; }	// Inactive();
//bool Ready:: correct_pin( bool isAboveMinBalance_, bool isActive_, int& nextStateId_ ){/*empty implementation*/ return false; } 	// CheckPin();

//bool Ready:: incorrect_pin( bool attemptsRemain_, int& nextStateId_ ){/*empty implementation*/ return false; }	// CheckPin();

//bool Ready:: attempts_remain(){/*empty implementation*/ return false; }											// CheckPin();
//bool Ready:: too_many_attempts(int& nextStateId_){/*empty implementation*/ return false; }						// CheckPin();

//bool Ready:: active(bool isAboveMinBalance_, int& nextStateId_){/*empty implementation*/ return false; }			// CheckPin();
//bool Ready:: inactive(int& nextStateId_){/*empty implementation*/ return false; }									// CheckPin();

//bool Ready:: above_min_balance(int& nextStateId_ ){/*empty implementation*/ return false; }						// CheckPin(); Inactive();
//bool Ready:: below_min_balance(int& nextStateId_ ){/*empty implementation*/ return false; }						// CheckPin(); Inactive();

//bool Ready:: activate( bool isPinCorrect_, bool isAboveMinBalance_, int& nextStateId ){/*empty implementation*/ return false; }		// Inactive();

//bool Ready:: sum_more_or_equal_to_min_balance( int& nextStateId_ ){/*empty implementation*/ return false; }		// Overdrawn();
//bool Ready:: sum_less_than_min_balance(){/*empty implementation*/ return false; }									// Overdrawn();
