package eco;

/**
 * This class represents wheat and associated methods, including the wheat
 * stockpile
 * 
 * @author phil, nate, will, connor
 * 
 */

public class Wheat {

	private static int tWheat;
	private static int wheatPrice;

	private static int maxwheat = 5000;
	private static int minwheat = 1000;

	public static int tWheat(int farmers) {
		tWheat += farmers * Farmer.getWheatProductionRate();
		return tWheat;
	}

	public static int eatWheat(int request) {
		if (tWheat < minwheat){
		  int toBuy = minwheat - tWheat;
	          tWheat += Economy.buyWheat(toBuy);		
		}	
		if (request > tWheat) {
			int diff = request - tWheat;
			tWheat = 0;
			return diff;
		} else {
			tWheat -= request;
			return 0;
		}
	}

	public static int gettWheat() {
		return tWheat;
	}

	public static void settWheat(int tWheat) {
		Wheat.tWheat = tWheat;
	}

	public static int getWheatPrice() {
		return wheatPrice;
	}

	public static void update(){
		if (tWheat > maxwheat){
			Economy.sellWheat(tWheat - maxwheat);
			tWheat = maxwheat;	
		}
	}	

	public static void setWheatPrice(int wheatPrice) {
		Wheat.wheatPrice = wheatPrice;
	}

}

@@ -11,17 +11,16 @@
 o;%0A%0A/**%0A
- 
 * This c
@@ -28,91 +28,125 @@
 ass 
-represents wheat and associated methods, including the wheat%0A * stockpile%0A * %0A * @a
+describes the international market for wheat,%0A* it manages wheat reserve goals and sells or buys to%0A* meet it.%0A*%0A* @A
 utho
@@ -155,34 +155,9 @@
 phil
-, nate, will, connor%0A * %0A 
+%0A
 */%0A%0A
@@ -169,21 +169,23 @@
 c class 
-Wheat
+Economy
  %7B%0A%0A%09pri
@@ -205,45 +205,19 @@
 nt t
-Wheat;%0A%09private static int wheatPrice
+reasury = 0
 ;%0A%0A%09
@@ -239,60 +239,23 @@
 int 
-max
 wheat
- = 5000;%0A%09private static int minwheat
+Price
  = 10
-00
 ;%0A%0A%09
@@ -268,25 +268,27 @@
  static int 
-t
+buy
 Wheat(int fa
@@ -289,276 +289,149 @@
 int 
-farmers) %7B%0A%09%09tWheat += farmers * Farmer.getWheatProductionRate();%0A%09%09return tWheat;%0A%09%7D%0A%0A%09public static int eatWheat(int request) %7B%0A%09%09if (tWheat %3C minwheat)%7B%0A%09%09  int toBu
+ammount)%7B%0A%09%09int neededMoney = wheatPrice * ammount;%0A%09%09if (neededMoney %3C= treasury)%7B%0A%09%09%09treasur
 y 
+-
 = 
-minwheat - tWheat;%0A%09          tWheat += Economy.buyWheat(toBuy);%09%09
+neededMoney;%0A%09%09%09return ammount;
 %0A%09%09%7D
-%09
 %0A%09%09
-if (request %3E tWheat) 
+else
 %7B%0A%09%09
@@ -439,109 +439,76 @@
 int 
-diff
+canBuy
  = 
+t
 re
-quest - tWheat;%0A%09%09%09tWheat = 0;%0A%09%09%09return diff;%0A%09%09%7D else %7B%0A%09%09%09tWheat -= request;%0A%09%09%09return 0;
+asury / wheatPrice;%0A%09%09%09treasury = 0;%0A%09%09%09return canBuy;%09%09
 %0A%09%09%7D
@@ -535,21 +535,67 @@
 int 
-gett
+sell
 Wheat(
-) %7B
+int ammount)%7B%0A%09%09treasury += wheatPrice * ammount;
 %0A%09%09r
@@ -600,21 +600,22 @@
 %09return 
-tWhea
+ammoun
 t;%0A%09%7D%0A%0A%09
@@ -637,324 +637,235 @@
 oid 
-settWheat(int tWheat) 
+updateMarket(int time)
 %7B%0A%09%09
-W
+w
 heat
-.tWheat = tWheat;%0A%09%7D%0A%0A%09public static int getWheatPrice() %7B%0A%09%09return wheatPrice;%0A%09%7D%0A%0A%09public static void update()%7B%0A%09%09if (tWheat %3E maxwheat)%7B%0A%09%09%09Economy.sellWheat(tWheat - maxwheat);%0A%09%09%09tWheat = maxwheat;%09%0A%09%09%7D%0A%09%7D%09%0A%0A%09public static void setWheatPrice(int whea
+Price += Util.randInt(-5, 5); // Biased to increase over time%0A%09%7D%0A%0A%09public static int getTreasury()%7B%0A%09%09System.out.println(treasury);%0A %09%09return treasury;%09%0A%09%7D%0A%0A%09public static int ge
 tPrice
+(
 )
- 
 %7B%0A%09%09
-Wheat.wheatPrice =
+return
  whe
@@ -875,12 +875,13 @@
 rice;%0A%09%7D
+%09
 %0A%0A%7D%0A

Update Economy.java