Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Java please! Design a class named StockBag which serves as a container of a group of Stock objects. Below is the UML of this class:
Java please!
Design a class named StockBag which serves as a container of a group of Stock objects. Below is the UML of this class: StockBag -stocks: Stock[] -name: String +StockBag 0 + StockBag(size: int) +addStock (stock: Stock): boolean tremoveStock(stock: Stock): boolean tremoveStock(stockSymbol: String) : boolean +searchForStock(stockSymbol: String): Stock +getStocks (): Stock[] +getStockCount(): int +isEmpty0: boolean Stock symbol Stock name Constructor, create StockBag instance, set stocks to default size (16) Constructor, create StockBag instance, set stocks size to size Add a stock into bag. Return true if operation succeed. Remove a stock from bag. Return true if operation succeed. Remove a stock by "symbol" from bag. Return true if operation succeed. Search stock in stocks by stock symbol, return a stock if found, otherwise null. Get list of stock currently in this StockBag Return number of stocks currently in StockBag Check if is StockBag empty ** For method addStock0", choose to implement one of the following logic to add a stock into the bag if stocks is full: (1) Expand the size of stock", this means user can always add new stock into the bag. Or, (2) Implement circular array of stock so the oldest" stock will be removed and new stock can be storedStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started