/* * (c) 1998-2000 The Brookings Institution, All Rights Reserved * * Permission to use this software and its documentation for non-commercial * purposes and without fee is hereby granted, provided this copyright statement * is included. Please contact us for permission for redistribution and other uses. *  * BROOKINGS MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,  * OR NON-INFRINGEMENT. BROOKINGS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY * LICENSEE AS A RESULT OF USING THIS SOFTWARE OR ITS DERIVATIVES. * * _Sugarscape_ * See _Growing Artificial Societies: Social Science from the Ground Up_ * Brookings Institution Press, The MIT Press * Joshua Epstein * jepstein@brook.edu * Robert Axtell * raxtell@brook.edu * * Miles Parker * mparker@brook.edu * http://www.brook.edu/es/dynamics/models/ascape * The Brookings Institution * Washington, D.C. * Alan Lockard * alockard@gmu.edu */package edu.brook.sugarscape;import java.lang.*;import java.awt.Color;import edu.brook.ascape.model.*;import edu.brook.ascape.util.*;/** * Source of a commodity, such as sugar or spice,  * in a sugarscape */public class CommoditySource {//    public static float moundness = .004f; // was .004    protected Cell owner; // Who (what cell) owns this commodity source        protected float capacity;    protected String name = "Generic commodity";        protected float quantity;  // was sugar    //    public double getValue(Object object) {//        return (1.0 - (double) ((SugarCell) object).getSugar() / (double) SugarCell.MAX_SUGAR);//    }    public void growBackEpsilon(float epsilon) {        //We test (instead of just incrementing) so we know if a view update        //is required or not        if (quantity < capacity) {            quantity += epsilon;            if (quantity > capacity) {                quantity = capacity;            }            owner.requestUpdate();        }    }    public void growBack1() {        //We test (instead of just incrementing) so we know if a view update        //is required or not        if (quantity < capacity) {            quantity++;            if (quantity > capacity) {                quantity = capacity;            }            owner.requestUpdate();        }    }    public void growBackInf() {        if (quantity < capacity) {            quantity = capacity;            owner.requestUpdate();        }    }    public float takeQuantity() {        float tempQuantity = quantity;        quantity = 0;        return tempQuantity;    }        public float getQuantity() {        return quantity;    }            public void setQuantity(float quantity) {        this.quantity = quantity;    }        public float getCapacity() {        return capacity;    }            public void setCapacity(float capacity) {        this.capacity = capacity;    }        public int getDefaultValue() {        return (int) quantity;    }        public String getName() {        return name;    }        public void setName(String name) {        this.name = name;    }    public void setOwner(Cell _cell) {        owner = _cell;    }    public Cell getOwner() {        return owner;    }}
