Question: 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!

Java please! Design a class named StockBag which serves as a container

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 stored

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!