#include "Overdrawn.h"

// Author: Steve Talbot

Overdrawn:: Overdrawn(){

}

Overdrawn:: ~Overdrawn(){
}

bool Overdrawn:: logout( int& nextStateId_ ){

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

	nextStateId_ = _stateIds->IDLE;

	return true;

}

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

	// “isLessThanMinBalance” is passed in from Account (not used, interface only) ..

	nextStateId_ = _stateIds->OVERDRAWN;

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

	getOutputProcessor()->display_menu();

	return result;

}

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

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

	if( isLessThanMinBalance_ == true ) {

		return sum_less_than_min_balance();

	} else {

		return sum_more_or_equal_to_min_balance( nextStateId_ );

	}

}

bool Overdrawn:: balance(){

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

	getOutputProcessor()->display_menu();

	return result;

}

bool Overdrawn:: 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 Overdrawn:: correct_pin( int& nextStateId_ ){

	nextStateId_ = _stateIds->INACTIVE;

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

	getOutputProcessor()->display_menu();

	return result;

}

bool Overdrawn:: incorrect_pin(){

	// no limit on number attempts to deactivate ..

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

	getOutputProcessor()->display_menu();

	return result;

}

bool Overdrawn:: sum_less_than_min_balance(){

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

	getOutputProcessor()->display_menu();

	return result;

}

bool Overdrawn:: sum_more_or_equal_to_min_balance( int& nextStateId_ ){

	nextStateId_ = _stateIds->READY;

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

	getOutputProcessor()->display_menu();

	return result;

}

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

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

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

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

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

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

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

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

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