package player.playeragent; import edu.neu.ccs.demeterf.demfgen.lib.List; import classes.*; /** Class for buying a derivative * @author animesh * */ public class BuyAgent { /** Returns the derivative to be bought from the list of derivatives on sale * @param dersForSale * @return {@link gen.Derivative} */ public static Derivative buyAgent(List dersForSale) { Derivative[] ders = new Derivative[dersForSale.length()]; dersForSale.toArray(ders); //return one of the derivatives on sale randomly int derToReturn = ((Double)(Math.random()*((Integer)(ders.length-1)).doubleValue())).intValue(); return ders[derToReturn]; } /** Returns a boolean to indicate whether a derivative should be bought or not * @return boolean */ public static boolean isBuyGood() { return ((Math.random()<0.5)?true:false); } }