hilodataimp.java

来自「著名的uncle Bob的Agile software development的」· Java 代码 · 共 52 行

JAVA
52
字号
package wmsdataimp;

public class HiLoDataImp implements java.io.Serializable,
                                    wmsdata.HiLoData
{
  private double itsHighValue;
  private double itsLowValue;
  private long itsHighTime;
  private long itsLowTime;

  public HiLoDataImp(double initial, long time)
  {
    itsHighValue = itsLowValue = initial;
    itsHighTime = itsLowTime = time;
  }

  public double getHighValue()
  { return itsHighValue; }
  public double getLowValue()
  { return itsLowValue; }
  public long getHighTime()
  { return itsHighTime; }
  public long getLowTime()
  { return itsLowTime; }

  public boolean currentReading(double current, long time)
  {
    boolean rtnVal = false;

    if(current > itsHighValue)
    {
      itsHighTime = time;
      itsHighValue = current;
      rtnVal = true;
    }
    else if(current < itsLowValue)
    {
      itsLowTime = time;
      itsLowValue = current;
      rtnVal = true;
    }

    return rtnVal;
  }

  public void newDay(double initial, long time)
  {
    itsLowValue = itsHighValue = initial;
    itsHighTime = itsLowTime = time;
  }
}

⌨️ 快捷键说明

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