Answered step by step
Verified Expert Solution
Link Copied!

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!

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions