⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 traderresult.java

📁 java的一系列产品中包括jsme,jmse,j2ee,本文件提供j2ee实现的源代码.
💻 JAVA
字号:
package stocktrader;

import java.io.Serializable;

/**
 * This class reflects the results of a buy/sell transaction.
 */
public final class TraderResult implements Serializable {

  public static final int SELL = 0;
  public static final int BUY  = 1;

  private int    numberTraded; // Number of shares really bought or sold
  private int    action;       // Whether shares were bought or sold
  private double price;        // Price shares were bought or sold at

  /**
   * Returns the number of shares and sales price for a
   * buy or sell transaction in a TraderResult object.
   */
  public TraderResult(int numberTraded, double price, int action) {
    this.numberTraded = numberTraded;
    this.price        = price;
    this.action       = action;
  }

  public int getNumberTraded() {
    return numberTraded;
  }

  public int getActionTaken() {
    return action;
  }

  public double getPrice() {
    return price;
  }

  public String toString() {
    String result = numberTraded + " shares";
    if(action == SELL) {
      result += "sold";
    } else {
      result += "bought";
    }
    result += " at a price of " + price;
    return result;
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -