jfreerails.controller
Class StockPriceCalculator

java.lang.Object
  extended by jfreerails.controller.StockPriceCalculator

public class StockPriceCalculator
extends java.lang.Object

Calculates the stock price for each of the players. Stock price = [Net worth + 5 * profit last year] / [ shares owned by public + 0.5 shares owned by other players] Let profit last year = 100,000 in the first year.

Author:
Luke

Nested Class Summary
static class StockPriceCalculator.StockPrice
           
 
Field Summary
private  ReadOnlyWorld w
           
 
Constructor Summary
StockPriceCalculator(ReadOnlyWorld w)
           
 
Method Summary
 StockPriceCalculator.StockPrice[] calculate()
           
(package private) static Money calStockPrice(long netWorth, long profitLastyear, int publicShares, int otherRRShares)
           
(package private)  boolean isFirstYear(int playerId)
          Returns true if the current time in the same year as the first transaction for the specified player.
(package private)  long netWorth(int playerId)
          Returns the players networth at the start of this year.
(package private)  long profitsLastYear(int playerId)
           
(package private)  int sharesOwnedByOtherPlayers(int playerId)
           
(package private)  int sharesOwnedByPublic(int playerId)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

w

private final ReadOnlyWorld w
Constructor Detail

StockPriceCalculator

public StockPriceCalculator(ReadOnlyWorld w)
Method Detail

calculate

public StockPriceCalculator.StockPrice[] calculate()

isFirstYear

boolean isFirstYear(int playerId)
Returns true if the current time in the same year as the first transaction for the specified player.


netWorth

long netWorth(int playerId)
Returns the players networth at the start of this year.


profitsLastYear

long profitsLastYear(int playerId)

sharesOwnedByPublic

int sharesOwnedByPublic(int playerId)

sharesOwnedByOtherPlayers

int sharesOwnedByOtherPlayers(int playerId)

calStockPrice

static Money calStockPrice(long netWorth,
                           long profitLastyear,
                           int publicShares,
                           int otherRRShares)