Back to project page SuperStocks.
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.
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; } }