Question: Please write in Java. 5. For this Section of the lab, you will implement an ADT Bag, using an Array. Since a Bag can in

Please write in Java.

Please write in Java. 5. For this Section of the lab, you

5. For this Section of the lab, you will implement an ADT Bag, using an Array. Since a Bag can in principle hold any type of object that the programmer chooses, your bag should hold BankAccount objects, as defined in Section 3 above. (30 pts] (a) Create Baglnterface. The interface should specify the following methods i. add(T newEntry) Adds the specified account to the bad remove() Removes an account from the bag remove(T anEntry) Removes the specified account from the bag contains(TanEntry) Returns true/false indicating if specified account exists getSize() Returns current number of accounts in the bag vi. toArray() Prints accounts in the bag to the console ii. iv. v. Note: Include Javadoc for each method outlined in the interface (b) Define the ArrayBag class, which will implement methods as specified in the interface. Be sure to document each method with Javadoc-style comments p 5 Feb 6, 2021 (c) Define a testing class whose main() method will use the ArrayBag class implemented above to: i. Create a mix of CheckingAccount and SavingsAccount objects and add to the bag. The bag must have at least 4 account objects ii. Print bag contents Hint: You will need to define print method in account class(es) to print bank account data. Sample output from print method could be as follows: SavingsAccount Number: 1 Create Date: "Feb 7, 2021" AccountBalance: $10 iii. Remove account(s), using both remove methods defined in the interface iv. Print bag size before and after account(s) removal(s) v. Pick an arbitrary amount to print all accounts with balance greater than the amount vi. Since a Bag can have duplicate items, be sure to have at least one duplicate account in the bag 5. For this Section of the lab, you will implement an ADT Bag, using an Array. Since a Bag can in principle hold any type of object that the programmer chooses, your bag should hold BankAccount objects, as defined in Section 3 above. (30 pts] (a) Create Baglnterface. The interface should specify the following methods i. add(T newEntry) Adds the specified account to the bad remove() Removes an account from the bag remove(T anEntry) Removes the specified account from the bag contains(TanEntry) Returns true/false indicating if specified account exists getSize() Returns current number of accounts in the bag vi. toArray() Prints accounts in the bag to the console ii. iv. v. Note: Include Javadoc for each method outlined in the interface (b) Define the ArrayBag class, which will implement methods as specified in the interface. Be sure to document each method with Javadoc-style comments p 5 Feb 6, 2021 (c) Define a testing class whose main() method will use the ArrayBag class implemented above to: i. Create a mix of CheckingAccount and SavingsAccount objects and add to the bag. The bag must have at least 4 account objects ii. Print bag contents Hint: You will need to define print method in account class(es) to print bank account data. Sample output from print method could be as follows: SavingsAccount Number: 1 Create Date: "Feb 7, 2021" AccountBalance: $10 iii. Remove account(s), using both remove methods defined in the interface iv. Print bag size before and after account(s) removal(s) v. Pick an arbitrary amount to print all accounts with balance greater than the amount vi. Since a Bag can have duplicate items, be sure to have at least one duplicate account in the bag

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To implement an ADT Bag using an array to hold BankAccount objects in Java youll need to follow these steps Step 1 Define the BagInterface java import javautil An interface that describes the operatio... View full answer

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!