I know that this is for an assignment, and not for a real system ... so feel free to ignore, as this response is just for a bit of realism.
Sourav Bws wrote:
2. Also, when the user wants to buy the stock at market price, I am thinking of storing the market prices in my DB tables. This can happen if I subscribe to the pricing system where the updates in prices are posted automatically. And my subscriber class would then populate the stock prices in the DB table.
With most trading systems / exchanges (that trade in equities), it is the trades that create the prices -- and not the other way. In other words, the prices are an indication of trades that already happened, and not the prices for future trades.
So, when you want to "buy at market", your "bid" is automatically matched with the lowest "ask", and traded. The new market price is then indicated by your trade. I believe that there are some safety nets for low volatility, etc., but you get the general idea.
Henry