function TransferManager() {
    this.errorState = true;     // Changes to 'false' if error occurs
    this.transferTable;
    this.size = 0;
    this.count = 0;
    this.newTips = new Tipbox("full");
    this.oldTips = new Tipbox("empty");
    this.currentGetTip;
    this.currentReturnTip;
    this.currentTransfer; 
    this.loadTransferTable = function(filePath) {
        try {
            this.transferTable = parseTransferTable(readFile(filePath));
            this.size = this.transferTable.length;
        } catch(e) {
            this.errorState = false;
            print(e);
        } finally {
            // Overkill perhaps..
            if(typeof this.transferTable === "undefined") {
                this.errorState = false;
            } else if(this.transferTable.length === 0) {
                this.errorState = false;
            }
        }
    }
    this.increment = function(changeTip) {
        if(typeof changeTip === "undefined" || typeof changeTip !== "boolean") {
            changeTip = true;
        }
        if(changeTip) {
            this.currentGetTip = this.newTips.getNextPosition();
            this.currentReturnTip = this.oldTips.getNextPosition();
        }
        this.currentTransfer = this.transferTable[this.count];
        this.count++;
    }
    this.hasNext = function() {
        return (this.count < this.size);
    }
    this.getCount = function() {
        return this.count;
    }
    this.getNewTipSelection = function() {
        return [this.currentGetTip];
    }
    this.getReturnTipSelection = function() {
        return [this.currentReturnTip];
    }
    this.getVolume = function() {
        return this.currentTransfer.volume;
    }
    this.getSourceSelection = function() {
        return [this.currentTransfer.source];
    }
    this.getDestinationSelection = function() {
        return [this.currentTransfer.destination];
    }
}
/*
 Class composition that includes all underlying code for handling single-tip
 transfers.
*/
Class composition that includes all underlying code for handling single-tip
transfers.
Class composition that includes all underlying code for handling single - tip transfers .
function TransferManager() {
    this.errorState = true;     
    this.transferTable;
    this.size = 0;
    this.count = 0;
    this.newTips = new Tipbox("full");
    this.oldTips = new Tipbox("empty");
    this.currentGetTip;
    this.currentReturnTip;
    this.currentTransfer; 
    this.loadTransferTable = function(filePath) {
        try {
            this.transferTable = parseTransferTable(readFile(filePath));
            this.size = this.transferTable.length;
        } catch(e) {
            this.errorState = false;
            print(e);
        } finally {
            if(typeof this.transferTable === "undefined") {
                this.errorState = false;
            } else if(this.transferTable.length === 0) {
                this.errorState = false;
            }
        }
    }
    this.increment = function(changeTip) {
        if(typeof changeTip === "undefined" || typeof changeTip !== "boolean") {
            changeTip = true;
        }
        if(changeTip) {
            this.currentGetTip = this.newTips.getNextPosition();
            this.currentReturnTip = this.oldTips.getNextPosition();
        }
        this.currentTransfer = this.transferTable[this.count];
        this.count++;
    }
    this.hasNext = function() {
        return (this.count < this.size);
    }
    this.getCount = function() {
        return this.count;
    }
    this.getNewTipSelection = function() {
        return [this.currentGetTip];
    }
    this.getReturnTipSelection = function() {
        return [this.currentReturnTip];
    }
    this.getVolume = function() {
        return this.currentTransfer.volume;
    }
    this.getSourceSelection = function() {
        return [this.currentTransfer.source];
    }
    this.getDestinationSelection = function() {
        return [this.currentTransfer.destination];
    }
}
function TransferManager ( ) { this . errorState = true ; this . transferTable ; this . size = 0 ; this . count = 0 ; this . newTips = new Tipbox ( "full" ) ; this . oldTips = new Tipbox ( "empty" ) ; this . currentGetTip ; this . currentReturnTip ; this . currentTransfer ; this . loadTransferTable = function ( filePath ) { try { this . transferTable = parseTransferTable ( readFile ( filePath ) ) ; this . size = this . transferTable . length ; } catch ( e ) { this . errorState = false ; print ( e ) ; } finally { if ( typeof this . transferTable === "undefined" ) { this . errorState = false ; } else if ( this . transferTable . length === 0 ) { this . errorState = false ; } } } this . increment = function ( changeTip ) { if ( typeof changeTip === "undefined" || typeof changeTip !== "boolean" ) { changeTip = true ; } if ( changeTip ) { this . currentGetTip = this . newTips . getNextPosition ( ) ; this . currentReturnTip = this . oldTips . getNextPosition ( ) ; } this . currentTransfer = this . transferTable [ this . count ] ; this . count ++ ; } this . hasNext = function ( ) { return ( this . count < this . size ) ; } this . getCount = function ( ) { return this . count ; } this . getNewTipSelection = function ( ) { return [ this . currentGetTip ] ; } this . getReturnTipSelection = function ( ) { return [ this . currentReturnTip ] ; } this . getVolume = function ( ) { return this . currentTransfer . volume ; } this . getSourceSelection = function ( ) { return [ this . currentTransfer . source ] ; } this . getDestinationSelection = function ( ) { return [ this . currentTransfer . destination ] ; } }
Class composition that includes all underlying code for handling single-tip
transfers.
Class composition that includes all underlying code for handling single - tip transfers .
// Changes to 'false' if error occurs // Overkill perhaps..