/**
 * @fileoverview
 * Specialised Object Functions
 * $Log: packPrice.js,v $
 * Revision 1.3  2006/02/13 21:25:42  mikeb
 * Features required for   tongueAndGroove.js  completed
 *
 * Revision 1.2  2006/01/26 22:58:00  mikeb
 * First commit
 *
 * @author © Copyright Mike Brockington 2004 - 2006 All rights reserved.
 * @version $Revision: 1.3 $
 * This version, Copyright: $Date: 2006/02/13 21:25:42 $
 */


/*
 * This constructor defines an object to handle calculations using discrete objects, rather than continuous numbers
 * Concrete class - based on simpleCalculator(), with details of required fields and calculations added
 */
function packPriceObject(intAdjustedTotal, intSingleItemPrice, intPackSize, intPackPrice)
{
    this.basicPrice        = intAdjustedTotal * intSingleItemPrice;
    var approxPackQuantity = (intAdjustedTotal / intPackSize);
    this.maxPackQuantity   = Math.ceil(approxPackQuantity);
    this.minPackQuantity   = this.maxPackQuantity - 1;
    this.unitsRequired     = intAdjustedTotal - (this.minPackQuantity * intPackSize);
    this.maxPackCost       = (this.maxPackQuantity * intPackPrice);
    this.minPackCost       = (this.minPackQuantity * intPackPrice);
    this.finalPackCost     = 0;
    this.boardCost         = (this.unitsRequired * intSingleItemPrice);
    this.packsRequired     = 0;
    if(this.maxPackCost > (this.minPackCost + this.boardCost))
    {
        this.bestPrice      = this.minPackCost + this.boardCost;
        this.finalPackCost  = this.minPackCost;
        this.packsRequired  = this.minPackQuantity;
    }else{
        this.bestPrice      = this.maxPackCost;
        this.unitsRequired  = 0;
        this.boardCost      = 0;
        this.finalPackCost  = this.maxPackCost;
        this.packsRequired  = this.maxPackQuantity;
    }
}


// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
packPriceObject.prototype.getResultText = function()
{
    var resultString = "Results Function Not complete: getResultText() [packPrice.js]";
    return resultString;
}

packPriceObject.prototype.getResultHTML = function()
{
    var resultString = "<br>Results Function Not complete: getResultHTML() [packPrice.js]";
    return resultString;
}

packPriceObject.prototype.getResultArray = function()
{
    var resultArray = ["Results Function Not complete: getResultArray() [packPrice.js]"];
    return resultArray;
}


