uk.ac.liv.auction.core
Class Shout

java.lang.Object
  extended byuk.ac.liv.auction.core.Shout
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable, java.io.Serializable
Direct Known Subclasses:
Shout.MutableShout

public class Shout
extends java.lang.Object
implements java.lang.Comparable, java.lang.Cloneable, java.io.Serializable

A class representing a shout in an auction. A shout may be either a bid (offer to buy) or an ask (offer to sell).

Shouts are mutable within this package for performance reasons, hence care should be taken not to rely on, e.g. shouts held in collections remaining constant.

Version:
$Revision: 1.38 $
Author:
Steve Phelps
See Also:
Serialized Form

Nested Class Summary
static class Shout.MutableShout
          A Shout that is publically mutable.
 
Field Summary
protected  TradingAgent agent
          The agent placing this offer
protected  Shout child
          The child of this shout.
protected  long id
          The unique id of this shout
protected  boolean isBid
          True if this shout is a bid.
protected  double price
          The price of this offer
protected  int quantity
          The number of items offered/wanted.
 
Constructor Summary
Shout()
           
Shout(Shout existing)
           
Shout(TradingAgent agent)
           
Shout(TradingAgent agent, int quantity, double price, boolean isBid)
           
 
Method Summary
 java.lang.Object clone()
           
 int compareTo(java.lang.Object o)
           
 TradingAgent getAgent()
           
 Shout getChild()
          Get the child of this shout.
 long getId()
           
 double getPrice()
           
 int getQuantity()
           
 int hashCode()
           
 boolean isAsk()
           
 boolean isBid()
           
 boolean isValid()
           
static double maxPrice(Shout s1, Shout s2)
           
static double minPrice(Shout s1, Shout s2)
           
 boolean satisfies(Shout other)
           
 java.lang.String toPrettyString()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

quantity

protected int quantity
The number of items offered/wanted.


price

protected double price
The price of this offer


agent

protected TradingAgent agent
The agent placing this offer


isBid

protected boolean isBid
True if this shout is a bid. False if this shout is an ask.


id

protected long id
The unique id of this shout


child

protected Shout child
The child of this shout.

Constructor Detail

Shout

public Shout(TradingAgent agent,
             int quantity,
             double price,
             boolean isBid)

Shout

public Shout(Shout existing)

Shout

public Shout(TradingAgent agent)

Shout

public Shout()
Method Detail

getQuantity

public int getQuantity()

getPrice

public double getPrice()

getAgent

public TradingAgent getAgent()

isBid

public boolean isBid()

isAsk

public boolean isAsk()

satisfies

public boolean satisfies(Shout other)

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable

isValid

public boolean isValid()

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Throws:
java.lang.CloneNotSupportedException

toString

public java.lang.String toString()

toPrettyString

public java.lang.String toPrettyString()

maxPrice

public static double maxPrice(Shout s1,
                              Shout s2)

minPrice

public static double minPrice(Shout s1,
                              Shout s2)

getChild

public Shout getChild()
Get the child of this shout. Shouts have children when they are split().

Returns:
The child Shout object, or null if this Shout is childless.

getId

public long getId()

hashCode

public int hashCode()