userId.symbol; has a current price. BuyStocks()
boolean signUp(String userId, String name, int initialWalletAmount)
userId is always unique and non blank.true if the user is created. otherwise do nothing and return false if called with a duplicate or blank userId. boolean adminAddOrUpdateStock(String symbol, int price)
true if the stock is added/updated; otherwise false. List<String> listAvailableStocks()
"SYMBOL PRICE".SYMBOL for deterministic output. boolean buyStock(String userId, String symbol, int quantity)
1≤ quantity < 10,000.symbol must be in the available stock list.false if the wallet balance is insufficient, or inputs are invalid.true and updates wallet + portfolio on success. boolean sellStock(String userId, String symbol, int quantity)
quantity > 0.quantity shares of symbol.false if holdings are insufficient, or inputs are invalid.true and updates wallet + portfolio on success. int getWalletBalance(String userId)
-1 if userId does not exist. List<String> getPortfolio(String userId)
"SYMBOL QUANTITY".QUANTITY > 0.SYMBOL for deterministic output.userId does not exist.1 <= userId.length() <= 30, 1 <= name.length() <= 601 <= symbol.length() <= 10false, the system state must remain unchanged for that operation.BuyStocks() → (constructor)adminAddOrUpdateStock(symbol="AAPL", price=100) → trueadminAddOrUpdateStock(symbol="TSLA", price=250) → truesignUp(userId="u1", name="Asha", initialWalletAmount=1000) → truebuyStock(userId="u1", symbol="AAPL", quantity=5) → truegetWalletBalance(userId="u1") → 500getPortfolio(userId="u1") → ["AAPL 5"]sellStock(userId="u1", symbol="AAPL", quantity=2) → truegetWalletBalance(userId="u1") → 700getPortfolio(userId="u1") → ["AAPL 3"]listAvailableStocks() → ["AAPL 100", "TSLA 250"]BuyStocks() → (constructor)adminAddOrUpdateStock(symbol="GOOG", price=300) → trueadminAddOrUpdateStock(symbol="AMZN", price=200) → truelistAvailableStocks() → ["AMZN 200", "GOOG 300"]signUp(userId="u2", name="Ravi", initialWalletAmount=250) → truesignUp(userId="u2", name="Ravi Again", initialWalletAmount=999) → falsebuyStock(userId="u2", symbol="NFLX", quantity=1) → falsebuyStock(userId="u2", symbol="GOOG", quantity=1) → falsebuyStock(userId="u2", symbol="AMZN", quantity=1) → truegetWalletBalance(userId="u2") → 50getPortfolio(userId="u2") → ["AMZN 1"]sellStock(userId="u2", symbol="AMZN", quantity=2) → falsesellStock(userId="u2", symbol="AMZN", quantity=1) → truegetWalletBalance(userId="u2") → 250getPortfolio(userId="u2") → []getWalletBalance(userId="unknown") → -1getPortfolio(userId="unknown") → []