home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Extras / ODesign / SetupPSE.exe / data.z / Trade.java < prev    next >
Encoding:
Java Source  |  1997-01-24  |  1.2 KB  |  56 lines

  1. package COM.odi.demo.pport;
  2.  
  3. /**
  4.  *      <H3>Copyright (C) Object Design Inc. 1996, 1997</H3>
  5.  *
  6.  * A Trade represents the purchase or sale of some amount of some
  7.  * security on some date.
  8.  */
  9.  
  10. import COM.odi.*;
  11.  
  12. final
  13. public class Trade
  14. {
  15.   /* The security that was bought or sold. */
  16.  
  17.   public Security security;
  18.  
  19.   /* The date on which the trade occurred. */
  20.  
  21.   public TradeDate date;
  22.  
  23.   /* The amount by which our position changed.  A positive delta
  24.      means that we bought some shares, and a negative delta means
  25.      that we sold some shares. */
  26.  
  27.   public int delta;
  28.  
  29.   /* Make a new Trade. */
  30.  
  31.   Trade(Security security, TradeDate date, int delta)
  32.   {
  33.     this.security = security;
  34.     this.date = date;
  35.     this.delta = delta;
  36.   }
  37.  
  38.   public String asString() {
  39.     StringBuffer tmpString = new StringBuffer(security.getSymbol());
  40.     while (tmpString.length() < 6) {
  41.       tmpString.append( " " );
  42.     }
  43.     tmpString.append( " | " );
  44.     tmpString.append(date.toString());
  45.     tmpString.append( " | " );
  46.     tmpString.append(Integer.toString(delta, 10));
  47.     return tmpString.toString();
  48.   }
  49.  
  50.   /* This class is never used as a persistent hash key. */
  51.   public int hashCode() {
  52.     return super.hashCode();
  53.   }
  54. }
  55.  
  56.