project coding a program

Get perfect grades by consistently using www.college-experts.com. Place your order and get a quality paper today. Take advantage of our current 20% discount by using the coupon code GET20


Order a Similar Paper Order a Different Paper

JAVA Project

1. SUMMARY

This project will simulate the stock market. This “sim” will include a trading account that tracks balance and stock

holdings, and it will include a stock market engine that will mimic the up and down movement of stocks. It will

also mimic the queue of requested trades that then get periodically resolved in bulk batches in order of trade

placement.

This project will involve the following:

– Inheritance

– Queue

– Random number generation for simulations

– Composite objects.

2. DETAILS

a. 8 classes required…

b. Account

– base class for different account types

i. Instance variables:

1. username

2. password

c. TradingAccount

– a specific type of account that carries a trading account balance and current stocks

held.

i. Inherits from Account class.

ii. Instance variables:

1. balance … float type

2. stockPositions … array of StockPosition type.

d. StockPosition

– Keeps track of a stock as far as amount of shares held.

i. Instance variables:

1. stockSymbol

2. shareCount … int type

e. TradeNode

– This holds details of a pending stock trade and is stored in a queue until execution

i. Instance variables:

1. stockSymbol

2. shareCount

3. buy … boolean type

4. nextTradeNode … TradeNode type

f. TradeQueue

– This manages the pending trade nodes in a queue for the StockMarketSim class

i. Instance variables:

1. headTradeNode

a. First/next TradeNode in line.

2. tailTradeNode

a. Last TradeNode in line

ii. Methods:

1. enqueue – Creates and adds a new TradeNode to end of queue.

a. Parameters as input.

i. sStockSymbol

ii. iPurchaseShareCount

iii. bBuy … this is true or false depending on buying or selling.

b. Creates new TradeNode and sets instance variables on that object.

i. If current headTradeNode is null then set both headTradeNode and tailTradeNode to this

new TradeNode.

ii. Else

1. Assign this new TradeNode to the tailTradeNode’s nextTradeNode variable.

2. Then assign the new TradeNode to the tailTradeNode variable.

3. NOTE: #1 above adds the new node to the end of the line by chaining it to the current

end of line tail node. #2 above then switches the variable of tailTradeNode to point to

the one you just added. The object that was the tail trade node before #2 is still there

in memory because it’s referenced by the node ahead of it. We just no longer have a

direct reference to it as it’s now in the middle of the line somewhere, and we have a

new tail or end of line node.

2. dequeue – This returns the head TradeNode (the next in line) and makes the second in the queue now the first in line.

a. Parameters as input.

i. None

b. If current headTradeNode is null, then return null.

c. Else

i. Creates temporary new TradeNode object and assigns the current headTradeNode to it.

ii. Assigns headTradeNode.nextTradeNode to headTradeNode.

iii. Returns the temporary TradeNode object to method caller.

g. Stock

– Simply holds a stock symbol and price for the stock engine

i. Instance variable:

1. stockSymbol

2. pricePerShare … int type

3. lastMoveUp … boolean type

h. StockEngine

i. Constructor:

1. Instantiates a new Random class and places in instance variable.

2. Initializes at least 3 stock objects with stock symbols and uses the rand object to generate

beginning prices.

3. Instantiates and fills stocks instance array in this class with these 3 stock objects.

ii. Instance variables:

1. rand – Random object instantiated in constructor.

2. stocks – array of all stocks in this stock market.

iii. Methods:

1. cycleTurn – This goes through each stock in the array and adjusts the price due to a random number algorithm.

a. Adjusts each stock in array using nextInt method on random object that limits moves to 3 or under.

i. Algorithm for creating random up or down will be reviewed in class.

1. This algorithm must make it more likely for stock to go the same way (up or down) as

the last move it made (stored in lastMoveUp). This allows for a stock to trend, rather

than completely switching up to down and back every turn and not moving very

much.

b. Sets the lastMoveUp variable of each stock based on up or down move.

c. Prints out current stock symbols and their values once adjusted.

d. No input params to method nor returns values back to method caller.

i. StockMarketSim

i. Instance variables:

1. tradingAccount

2. tradeQueue

3. stockEngine

ii. Methods:

1. start – Does all the following:

a. Instantiates all instance variables of this class.

b. Initializes any values in those classes that are required for functionality, such as initial values

for tradingAccount object.

i. NOTE: Only one tradingAccount is being created for this project to keep it simple.

ii. NOTE: tradingAccount’s stockPositions array should be instantiated to a size of 3, one for

each of the three stocks you created in StockEngine. And initialize the instance variables

on each of the three objects for the array with stock symbol for each and shareCount set to

0.

c. Calls runUI method.

2. runUI – Does all the following:

a. Runs a menu loop until user types in “exit” or balance is less than 1 in account.

b. Menu Loop: Gives user menus with numbers for each choice, and each menu’s functionality is

detailed here:

i. Account status.

1. Displays all info in tradingAccount.

ii. Trade stocks.

1. “Which stock do you want to buy/sell?” (get input)

2. “How many shares?” (get input)

3. “Buy or sell?” (get input)

4. Call enqueue on tradeQueue object passing in inputs gathered from user.

iii. Cycle Stock Market!

1. Calls cycleTurn on stockEngine. (This is done before processTrades so user isn’t

always getting precisely the price he/she wants to make more challenging.)

2. Calls processTrades in this class.

c. After loop exit, shows ending balance and Sim-ending message.

3. processTrades – Does all the following:

a. Processes all nodes in tradeQueue using dequeue method on tradeQueue.

i. This method must properly figure out sell or buy, calculate number of shares and current

stock price, and adjust both tradingAccount balance and stockPositions instance values.

j. StockMarketSim_Test

i. One main method that instantiates and starts a StockMarketSim instance.

Writerbay.net

Do you need help with this or a different assignment? We offer CONFIDENTIAL, ORIGINAL (Turnitin/LopesWrite/SafeAssign checks), and PRIVATE services using latest (within 5 years) peer-reviewed articles. Kindly click on ORDER NOW to receive an A++ paper from our masters- and PhD writers.

Get a 15% discount on your order using the following coupon code SAVE15


Order a Similar Paper Order a Different Paper