Interface Trader

All Known Implementing Classes:
TraderImpl

public interface Trader

Interface to be implmented by TraderImplementation. CS 537, Spring 2007, Project 2.


Method Summary
 void deliver(int amt)
          Accepts a delivery from the supplier.
 void get(Order order)
          A request from a brewer.
 Order getAmountOnHand()
          Reports on the total amount of resources held by this Trader.
 void swap(Grain what, int amt)
          Responds to a swap request from another Trader.
 

Method Detail

getAmountOnHand

Order getAmountOnHand()
Reports on the total amount of resources held by this Trader.

Returns:
an indication of the amount of each type of grain stocked by this Trader.

get

void get(Order order)
         throws InterruptedException
A request from a brewer. The caller is blocked until the request can be completely filled.

Parameters:
order - the number of bushels needed of each type of grain.
Throws:
InterruptedException - if the current thread is interrupted while waiting for the order to be filled.

swap

void swap(Grain what,
          int amt)
          throws InterruptedException
Responds to a swap request from another Trader. The other Trader calls this method to request a trade of a particular type of grain for this Trader's specialty. Delays the caller until this Trader can complete the swap.

Parameters:
what - the type of grain the other Trader wants to swap.
amt - the number of bushels to swap.
Throws:
InterruptedException - if the current thread is interrupted while waiting for the swap to succeed.

deliver

void deliver(int amt)
Accepts a delivery from the supplier. The supplier calls this method to deliver some of this Trader's specialty grain.

Parameters:
amt - the number of ounces of this Trader's specialty being delivered.