package eco;

/**
* This class describes the international market for wheat,
* it manages wheat reserve goals and sells or buys to
* meet it.
*
* @Author phil
*/

public class Economy {

	private static int treasury = 0;

	private static int wheatPrice = 10;

	public static int buyWheat(int ammount){
		int neededMoney = wheatPrice * ammount;
		if (neededMoney <= treasury){
			treasury -= neededMoney;
			return ammount;
		}
		else{
			int canBuy = treasury / wheatPrice;
			treasury = 0;
			return canBuy;		
		}
	}

	public static int sellWheat(int ammount){
		treasury += wheatPrice * ammount;
		return ammount;
	}

	public static void updateMarket(int time){
		wheatPrice += Util.randInt(-5, 7); // Biased to increase over time
	}

	public static int getTreasury(){
		return treasury;	
	}

	public static int getPrice(){
		return wheatPrice;
	}	

}

@@ -11,16 +11,17 @@
 o;%0A%0A/**%0A
+ 
 * This c
@@ -29,125 +29,91 @@
 ass 
-describes the international market for wheat,%0A* it manages wheat reserve goals and sells or buys to%0A* meet it.%0A*%0A* @A
+represents wheat and associated methods, including the wheat%0A * stockpile%0A * %0A * @a
 utho
@@ -118,17 +118,42 @@
 hor phil
-%0A
+, nate, will, connor%0A * %0A 
 */%0A%0Apubl
@@ -165,15 +165,13 @@
 ass 
-Economy
+Wheat
  %7B%0A%0A
@@ -191,27 +191,53 @@
 ic int t
-reasury = 0
+Wheat;%0A%09private static int wheatPrice
 ;%0A%0A%09priv
@@ -255,23 +255,60 @@
 int 
+max
 wheat
-Price
+ = 5000;%0A%09private static int minwheat
  = 10
+00
 ;%0A%0A%09
@@ -329,11 +329,9 @@
 int 
-buy
+t
 Whea
@@ -340,149 +340,276 @@
 int 
-ammount)%7B%0A%09%09int neededMoney = wheatPrice * ammount;%0A%09%09if (neededMoney %3C= treasury)%7B%0A%09%09%09treasur
+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
 y 
--
 = 
-neededMoney;%0A%09%09%09return ammount;
+minwheat - tWheat;%0A%09          tWheat += Economy.buyWheat(toBuy);%09%09
 %0A%09%09%7D
+%09
 %0A%09%09
-else
+if (request %3E tWheat) 
 %7B%0A%09%09
@@ -617,76 +617,109 @@
 int 
-canBuy
+diff
  = 
-t
 re
-asury / wheatPrice;%0A%09%09%09treasury = 0;%0A%09%09%09return canBuy;%09%09
+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;
 %0A%09%09%7D
@@ -746,83 +746,36 @@
 int 
-sell
+gett
 Wheat(
-int ammount
 )
+ 
 %7B%0A%09%09
-t
 re
-asury += wheatPrice * ammount;%0A%09%09return ammoun
+turn tWhea
 t;%0A%09
@@ -801,202 +801,324 @@
 oid 
-updateMarket(int time)
+settWheat(int tWheat) 
 %7B%0A%09%09
-w
+W
 heat
-Price += Util.randInt(-5, 7); // Biased to increase over time%0A%09%7D%0A%0A%09public static int getTreasury()%7B%0A%09%09return treasury;%09%0A%09%7D%0A%0A%09public static int ge
+.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
 tPrice
-(
 )
+ 
 %7B%0A%09%09
-return
+Wheat.wheatPrice =
  whe
@@ -1128,13 +1128,12 @@
 rice;%0A%09%7D
-%09
 %0A%0A%7D%0A

Update Economy.java