package obj;

import classes.Main;
import classes.StoreCustomerSignal;
import classes.StoreCustomerSignal.PriceLevel;

public class Customer implements Runnable {

	public enum affluency{HIGHSPENDER,MIDSPENDER,LOWSPENDER};

	private StoreCustomerSignal		customerStore;
	private Store					store;
	private affluency 				buyerType;
	private PriceLevel				priceLevel;
	private int 					buyQuantity;

	public Customer(int id, StoreCustomerSignal customerStore) {
		this.customerStore = customerStore;
	}

/**
 * 	
 * @param enumVal willing to buy at low-high price
 * @param numToBuy quantity desired from store
 * @param sig signal between store and this customer
 * @param newStore reference to store
 */
public Customer(affluency enumVal,int numToBuy, StoreCustomerSignal sig, Store newStore) {
		buyerType = enumVal;
		customerStore = sig;
		store = newStore;
		buyQuantity = numToBuy;

		switch(buyerType) {

		case HIGHSPENDER: 	
			priceLevel = priceLevel.HIGHPRICE;
			break;
		case MIDSPENDER: 	
			priceLevel = priceLevel.MIDPRICE;
			break;
		case LOWSPENDER: 	
			priceLevel = priceLevel.LOWPRICE;
			break;
		default: 			
			break;
		}
	}
	
	// do this until you're dead
	@Override
	public void run() {
		while (Main.isRunning()) {
			customerStore.checkSale(priceLevel);	// if: priceLevel is not satisfactory, wait()
			//Store.buy(byQuantity); // buy all the jeans you  want!
			try {
				wait(Main.waitAfterBuy);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
}

@@ -1379,16 +1379,20 @@
   want!%0A
+%09%09%09%0A
 %09%09%09try %7B
@@ -1463,47 +1463,8 @@
 ) %7B%0A
-%09%09%09%09// TODO Auto-generated catch block%0A
 %09%09%09%09

work on customer