Android Open Source - SuperStocks Smooth Market






From Project

Back to project page SuperStocks.

License

The source code is released under:

GNU General Public License

If you think the Android project SuperStocks listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package io.binroot.stocks;
//www  . j  a va 2  s .co m
/**
 * Created by binroot on 6/28/14.
 */
public class SmoothMarket implements StockMarketEmulator {
    private float mPrevious = 200;
    private float mCurrent = 100;
    private int mHeight;

    public SmoothMarket(float current, int height) {
        mCurrent = current;
        mHeight = height - 20;
    }


    @Override
    public float next() {
        float newVal = mCurrent;
        if (Math.abs(mPrevious - mCurrent) <= 1) {
            newVal += Math.random()*5;
        } else {
            newVal -= Math.random()*30-15;
        }
        if (newVal <= 0) {
            newVal += Math.random()*100;
        } else if (newVal >= mHeight) {
            newVal -= Math.random()*100;
        }
        mPrevious = mCurrent;
        mCurrent = newVal;
        return newVal;
    }
}




Java Source Code List

io.binroot.stocks.ApplicationTest.java
io.binroot.stocks.BaseGameActivity.java
io.binroot.stocks.BaseGameUtils.java
io.binroot.stocks.GameActivity.java
io.binroot.stocks.GameHelper.java
io.binroot.stocks.GameThread.java
io.binroot.stocks.SmoothMarket.java
io.binroot.stocks.StockMarketEmulator.java
io.binroot.stocks.StockPriceView.java