function Tipbox(tips) {
	this.tipCount = parseInt(tips, 10);
	this.tipCount = (!this.tipCount || this.tipCount < 0) ? 0 : this.tipCount;
	// Return the row of the lower right-most tip:
	this.getRow = function(n) {
		return (n-1) % 8 + 1;
	}
	// Return the column of the lower right-most tip:
	this.getColumn = function(n) {
		return ((n-1) - (n-1) % 8) / 8 + 1;
	}
	this.hasTip = function() {
		return this.tipCount > 0;
	}
	this.isEmpty = function() {
		return this.tipCount < 1;
	}
	// Methods takeTip and putTip returns the position of the lower
	// right-most tip and updates 'tipCount' if "successful":
	this.takeTip = function() {
		var tip = new Array(2);
		// Find the "last" tip:
		tip[0] = this.getRow(this.tipCount);
		tip[1] = this.getColumn(this.tipCount);
		if(tip[0] > 0 && tip[1] > 0) {
			this.tipCount--;
		} else {
			tip = undefined;
		}
		return tip;
	}
	this.putTip = function() {
		var temp = this.tipCount + 1;
		var tip = new Array(2);
		// Find the "last" empty position:
		tip[0] = this.getRow(temp);
		tip[1] = this.getColumn(temp);
		if(tip[1] < 13 && tip[0] > 0 && tip[1] > 0) {
			this.tipCount++;
		} else {
			tip = undefined;
		}
		return tip;
	}
	// The following methods allow getting coords without incrementation:
	this.getNextTipPosition =  function() {
		var tip = new Array(2);
		// Find the "last" tip:
		tip[0] = this.getRow(this.tipCount);
		tip[1] = this.getColumn(this.tipCount);
		if(tip[0] < 1 || tip[1] < 1) {
			tip = undefined;
		}
		return tip;
	}
	this.getNextEmptyPosition = function() {
		var temp = this.tipCount + 1;
		var tip = new Array(2);
		// Find the "last" empty position:
		tip[0] = this.getRow(temp);
		tip[1] = this.getColumn(temp);
		if(tip[1] > 12 || tip[0] < 1 || tip[1] < 1) {
			tip = undefined;
		}
		return tip;
	}
	this.increment = function() {
		this.tipCount++;
	}
	this.decrement = function() {
		this.tipCount--;
	}
}
/*
Tip box class to handle single-tip processes filling tips columns-wise
from up/left to down/right, i.e. A1, B1...H1, A2...
*/
Tip box class to handle single-tip processes filling tips columns-wise
from up/left to down/right, i.e.
Tip box class to handle single - tip processes filling tips columns - wise from up / left to down / right i . e .
function Tipbox(tips) {
	this.tipCount = parseInt(tips, 10);
	this.tipCount = (!this.tipCount || this.tipCount < 0) ? 0 : this.tipCount;
	this.getRow = function(n) {
		return (n-1) % 8 + 1;
	}
	this.getColumn = function(n) {
		return ((n-1) - (n-1) % 8) / 8 + 1;
	}
	this.hasTip = function() {
		return this.tipCount > 0;
	}
	this.isEmpty = function() {
		return this.tipCount < 1;
	}
	this.takeTip = function() {
		var tip = new Array(2);
		tip[0] = this.getRow(this.tipCount);
		tip[1] = this.getColumn(this.tipCount);
		if(tip[0] > 0 && tip[1] > 0) {
			this.tipCount--;
		} else {
			tip = undefined;
		}
		return tip;
	}
	this.putTip = function() {
		var temp = this.tipCount + 1;
		var tip = new Array(2);
		tip[0] = this.getRow(temp);
		tip[1] = this.getColumn(temp);
		if(tip[1] < 13 && tip[0] > 0 && tip[1] > 0) {
			this.tipCount++;
		} else {
			tip = undefined;
		}
		return tip;
	}
	this.getNextTipPosition =  function() {
		var tip = new Array(2);
		tip[0] = this.getRow(this.tipCount);
		tip[1] = this.getColumn(this.tipCount);
		if(tip[0] < 1 || tip[1] < 1) {
			tip = undefined;
		}
		return tip;
	}
	this.getNextEmptyPosition = function() {
		var temp = this.tipCount + 1;
		var tip = new Array(2);
		tip[0] = this.getRow(temp);
		tip[1] = this.getColumn(temp);
		if(tip[1] > 12 || tip[0] < 1 || tip[1] < 1) {
			tip = undefined;
		}
		return tip;
	}
	this.increment = function() {
		this.tipCount++;
	}
	this.decrement = function() {
		this.tipCount--;
	}
}
function Tipbox ( tips ) { this . tipCount = parseInt ( tips , 10 ) ; this . tipCount = ( ! this . tipCount || this . tipCount < 0 ) ? 0 : this . tipCount ; this . getRow = function ( n ) { return ( n - 1 ) % 8 + 1 ; } this . getColumn = function ( n ) { return ( ( n - 1 ) - ( n - 1 ) % 8 ) / 8 + 1 ; } this . hasTip = function ( ) { return this . tipCount > 0 ; } this . isEmpty = function ( ) { return this . tipCount < 1 ; } this . takeTip = function ( ) { var tip = new Array ( 2 ) ; tip [ 0 ] = this . getRow ( this . tipCount ) ; tip [ 1 ] = this . getColumn ( this . tipCount ) ; if ( tip [ 0 ] > 0 && tip [ 1 ] > 0 ) { this . tipCount -- ; } else { tip = undefined ; } return tip ; } this . putTip = function ( ) { var temp = this . tipCount + 1 ; var tip = new Array ( 2 ) ; tip [ 0 ] = this . getRow ( temp ) ; tip [ 1 ] = this . getColumn ( temp ) ; if ( tip [ 1 ] < 13 && tip [ 0 ] > 0 && tip [ 1 ] > 0 ) { this . tipCount ++ ; } else { tip = undefined ; } return tip ; } this . getNextTipPosition = function ( ) { var tip = new Array ( 2 ) ; tip [ 0 ] = this . getRow ( this . tipCount ) ; tip [ 1 ] = this . getColumn ( this . tipCount ) ; if ( tip [ 0 ] < 1 || tip [ 1 ] < 1 ) { tip = undefined ; } return tip ; } this . getNextEmptyPosition = function ( ) { var temp = this . tipCount + 1 ; var tip = new Array ( 2 ) ; tip [ 0 ] = this . getRow ( temp ) ; tip [ 1 ] = this . getColumn ( temp ) ; if ( tip [ 1 ] > 12 || tip [ 0 ] < 1 || tip [ 1 ] < 1 ) { tip = undefined ; } return tip ; } this . increment = function ( ) { this . tipCount ++ ; } this . decrement = function ( ) { this . tipCount -- ; } }
Tip box class to handle single-tip processes filling tips columns-wise
from up/left to down/right, i.e.
Tip box class to handle single - tip processes filling tips columns - wise from up / left to down / right i . e .
// Return the row of the lower right-most tip: // Return the column of the lower right-most tip: // Methods takeTip and putTip returns the position of the lower // right-most tip and updates 'tipCount' if "successful": // Find the "last" tip: // Find the "last" empty position: // The following methods allow getting coords without incrementation: // Find the "last" tip: // Find the "last" empty position: