marketplace
Class BuyerAgent

java.lang.Object
  |
  +--ciagent.CIAgent
        |
        +--marketplace.BuyerAgent
Direct Known Subclasses:
BestBuyerAgent, BetterBuyerAgent

public class BuyerAgent
extends CIAgent

The BuyerAgent class implements a very simple buyer agent.

See Also:
Serialized Form

Field Summary
protected  BasicNegotiation current
           
protected  java.util.Hashtable inventory
           
protected  BuySellMessage msg
           
protected  java.util.Hashtable negotiations
           
protected  BasicNegotiation pending
           
protected  long totalSpent
           
protected  java.util.Vector wishList
           
 
Fields inherited from class ciagent.CIAgent
agentPlatform, children, DEFAULT_ASYNCTIME, DEFAULT_SLEEPTIME, name, parent, traceLevel
 
Constructor Summary
BuyerAgent()
          Creates a BuyerAgent object.
BuyerAgent(java.lang.String name)
          Creates a BuyerAgent object with the given name.
 
Method Summary
 java.lang.String getTaskDescription()
          Retrieves a description of what this agent is doing.
 void initialize()
          Registers with the facilitator and initializes its wish list.
(package private)  void negotiate(Offer offer, BuySellMessage msg)
          Accepts the offer if it is less than the strike price or offers a counter offer.
 void process()
          Does nothing.
 void processCIAgentEvent(CIAgentEvent e)
          Processes a CIAgentEvent.
 void processMessage(BuySellMessage msg)
          Processes a BuySellMessage received in a CIAgentEvent.
 void processTimerPop()
          Kicks off netotiations if there are items on the wish list and no negotiation is already in progress.
 
Methods inherited from class ciagent.CIAgent
addAgent, addCIAgentEventListener, addPropertyChangeListener, getAgent, getAgentPlatform, getAgents, getAsyncTime, getChildren, getCustomizerClass, getDisplayName, getName, getParent, getSleepTime, getState, getTraceLevel, notifyCIAgentEventListeners, postCIAgentEvent, processAsynchronousEvents, removeAgent, removeCIAgentEventListener, removePropertyChangeListener, reset, resumeAgentProcessing, setAgentPlatform, setAsyncTime, setName, setParent, setSleepTime, setState, setTraceLevel, startAgentProcessing, stopAgentProcessing, suspendAgentProcessing, trace
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

msg

protected BuySellMessage msg

current

protected BasicNegotiation current

wishList

protected java.util.Vector wishList

pending

protected BasicNegotiation pending

inventory

protected java.util.Hashtable inventory

totalSpent

protected long totalSpent

negotiations

protected java.util.Hashtable negotiations
Constructor Detail

BuyerAgent

public BuyerAgent()
Creates a BuyerAgent object.

BuyerAgent

public BuyerAgent(java.lang.String name)
Creates a BuyerAgent object with the given name.
Parameters:
Name - the String object the name of the agent
Method Detail

initialize

public void initialize()
Registers with the facilitator and initializes its wish list.
Overrides:
initialize in class CIAgent

getTaskDescription

public java.lang.String getTaskDescription()
Retrieves a description of what this agent is doing.
Returns:
the String object that contains the description
Overrides:
getTaskDescription in class CIAgent

process

public void process()
Does nothing.
Overrides:
process in class CIAgent

processTimerPop

public void processTimerPop()
Kicks off netotiations if there are items on the wish list and no negotiation is already in progress.
Overrides:
processTimerPop in class CIAgent

processCIAgentEvent

public void processCIAgentEvent(CIAgentEvent e)
Processes a CIAgentEvent.
Parameters:
e - the CIAgentEvent object that contains the message to be processed
Overrides:
processCIAgentEvent in class CIAgent

processMessage

public void processMessage(BuySellMessage msg)
Processes a BuySellMessage received in a CIAgentEvent.
Parameters:
msg - the BuySellMessage object to be processed

negotiate

void negotiate(Offer offer,
               BuySellMessage msg)
Accepts the offer if it is less than the strike price or offers a counter offer.
Parameters:
offer - the Offer object that contains the current offer
msg - the BuySellMessage object