Back to project page ZorbsCity.
The source code is released under:
GNU General Public License
If you think the Android project ZorbsCity listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package jonathan.geoffroy.zorbscity.model.helpers; //w ww . j av a2 s. c o m public class NeededList { private int needed[]; public NeededList() { needed = new int[ResourcesList.NB_RESOURCES]; } /** * * @param resourceType the resource type to check * @return true if the resource type is needed */ public boolean isNeeded(int resourceType) { assert(resourceType >= 0 && resourceType < ResourcesList.NB_RESOURCES); return needed[resourceType] != 0; } /** * Get the <resourceType> amount of needed * @param resourceType * @return the amount of the <resourceType> resource or 0 if this resource isn't needed */ public int amountNeeded(int resourceType) { assert(resourceType >= 0 && resourceType < ResourcesList.NB_RESOURCES); return needed[resourceType]; } /** * Set the <amountNeeded> amount of <resourceType> is needed * @param resourceType * @param amountNeeded */ public void addNeeded(int resourceType, int amountNeeded) { assert(resourceType >= 0 && resourceType < ResourcesList.NB_RESOURCES); needed[resourceType] = amountNeeded; } public void addAllNeeded(NeededList other) { for(int i = 0; i < needed.length; i++) { needed[i] = Math.max(needed[i], other.needed[i]); } } public int[] getNeeded() { return needed; } }