Using your IDE, define class BankAccount, with its 2 subclasses, Savings Account & Checking Account [25...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Using your IDE, define class BankAccount, with its 2 subclasses, Savings Account & Checking Account [25 pts] A. BankAccount class Instance Variable account Num createDate balance type Class Variable (static) bankName currentNumber Variable Type String String int String Variable Type String int Modifier public public public private B. Define the following methods for this class default private Note: The currentNumber is a static variable that should be initialized to 0. This value will be updated by incrementing its current value by 1 each time a new BankAccount object is created, and assigned to accountNum instance variable The incremented value should be assigned to the account Num variable of any new BankAccount instance that gets created by the constructor 2-arg constructor that uses accountNum, createDate (current date) 4-arg constructor that uses all four instance variables all getter and setter methods other supporting methods, as you deem appropriate C. Define main() method for this class that will: First print 'Welcome Message' Ask user which account and with what balance does it want to create Use Scanner to read user input Create 2 accounts Print account details - - 2. For this Section of the lab, you will use the MyArrayBag class you created in Assignment-1. Since a Bag can in principle hold any type of object that the programmer chooses, or as mandated by the application requirements, for this Section the bag object you created should hold BankAccount objects. [30 pts] (a) Before you begin testing the MyArrayBag class with BankAccount objects, write a method named 'equals(aBankAccountObj)' method. As the method signature indicates, the argument aBankAccountObj' will be bankaccount object you will be validating equality with. This method should return a boolean, to indicate whether or not the two objects are equal Hint: You will need to write the compareTo(aBankAccountObj) method, as discussed in class Your equals(aBankAccountObj) method can then be used in turn to call the compareTo(aBankAccountObj) method and then finally return a boolean based on what compare To method returned The logic to compare two bankaccount objects and determine whether or not they are equal is left to your discretion and will be acceptable (b) Create an adapter BankAccountTester that will use the MyArrayBag class to create a bag object and manipulate it using BankAccount objects: i. Create a mix of CheckingAccount and Savings Account objects and add to the bag. You must have at least 4 BankAccount objects in the bag Print bag contents Hint: You will need to define print method to print data of bank accounts to console iii. Remove account(s), using both remove methods (random and a specified account) as defined in the interface ii. 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 object in your bag 3. In this section you will implement an ADT Bag using Linked Data. For that, create a class named MyLinkedBag that should also implement the same BagInterface that was implemented by your MyArrayBag class in Assignment-1. As a result, your MyLinkedBag class will have to implement all methods defined in the interface. [30 points] This class should: (a) Have a private instance variable called 'num Nodes', whose initial value should be 0. This variable will store an integer value, which will represent the count of node elements in the bag at any point in time (b) Have a default instance variable called 'firstNode' that will store a node object, which will be implemented through an inner class called 'Node', as outlined below. This variable will represent the starting node that can then be used to traverse through all other nodes in the bag (c) Have a no-arg constructor (d) Have the following methods: add(aBankAccount) i. This method should add a bankaccount object and return true to indicate if add was successful and false otherwise This method should take a bankaccount object as an argument This method will create a new Node object and set its data attribute to the bankaccount object object and set the next attribute of the new node to be what was previously firstNode and the firstNode attribute to this newly created node Note: - - The add method should handle both conditions, of adding a node to an empty bag, and also the case if the bag had node(s) prior to this addition ii. contains(aBankAccount) - This method should check to see if aBankAccount object exists in the bag The method should return true if the object exists and false otherwise Note: Keep in mind since the bankAccount object is stored as data within the linked node, you will need to traverse through the nodes and compare each node's data object to object coming in as argument to find the match 7 iii. remove() This method should delete the first node of the bag This method should return true if successful and false otherwise Note: Once the deletion is completed, the firstNode attribute should point to what was previously the node next to first node iv. remove(aBankAccount) This method deletes aBankAccount object in the bag This method should return true if successful and false otherwise Note: As in the case of contains method above, you will need to traverse through the nodes and compare each node's data to find the match As in the case of contains method above, you will need a way to compare two aBankAccount objects objects to check equality v. toArray() - - The method should return an array all aBankAccount objects in the bag Keep in mind that since bank account objects are stored as data within the linked nodes of the bag, you will need to traverse through the nodes within the bag and build the array of aBankAccount objects as retrieved from each node 4. Since you are creating MyLinkedBag class, you will not be using an array anymore to store objects. Instead, you will be creating a Node class, as inner class within your MyLinkedBag class, to facilitate storage and retrieval of stored objects [20 points] This Node inner class should: (a) Have an instance variable called 'data', that will store objects of type BankAccount (b) Have an instance variable called 'next', that will store a Node object, which represents the node next to current node (c) Have a no-arg constructor (d) Have a 1-arg constructor, that takes an object as an argument (e) Have a 2-arg constructor, that takes an object and Node object as two arguments. This constructor should set the object to the data attribute and Node object to the next node attribute of the current node, as discussed in class (f) Have getters and setters for each of the 2 instance variables for the class 5. Define an adapter class, BuildBag, for testing, whose main() method will contain the code to perform testing. The method should do the following [20 points] Along the lines of testing with bankaccount objects for the array-based bag, do the following to test your Linked Bag (a) Create 2 CheckingAccount and 2 SavingsAccount objects, with appropriate data. The data required to create the bank accounts can be hard-coded in the main() method (b) Instantiate your LinkedBag class, using the appropriate constructor(s) (c) Add the 4 bank account objects created above to the LinkedBag object using the add() method (d) Remove a bank account object from the bag (e) Print bag contents with details for each BankAccount in the bag Using your IDE, define class BankAccount, with its 2 subclasses, Savings Account & Checking Account [25 pts] A. BankAccount class Instance Variable account Num createDate balance type Class Variable (static) bankName currentNumber Variable Type String String int String Variable Type String int Modifier public public public private B. Define the following methods for this class default private Note: The currentNumber is a static variable that should be initialized to 0. This value will be updated by incrementing its current value by 1 each time a new BankAccount object is created, and assigned to accountNum instance variable The incremented value should be assigned to the account Num variable of any new BankAccount instance that gets created by the constructor 2-arg constructor that uses accountNum, createDate (current date) 4-arg constructor that uses all four instance variables all getter and setter methods other supporting methods, as you deem appropriate C. Define main() method for this class that will: First print 'Welcome Message' Ask user which account and with what balance does it want to create Use Scanner to read user input Create 2 accounts Print account details - - 2. For this Section of the lab, you will use the MyArrayBag class you created in Assignment-1. Since a Bag can in principle hold any type of object that the programmer chooses, or as mandated by the application requirements, for this Section the bag object you created should hold BankAccount objects. [30 pts] (a) Before you begin testing the MyArrayBag class with BankAccount objects, write a method named 'equals(aBankAccountObj)' method. As the method signature indicates, the argument aBankAccountObj' will be bankaccount object you will be validating equality with. This method should return a boolean, to indicate whether or not the two objects are equal Hint: You will need to write the compareTo(aBankAccountObj) method, as discussed in class Your equals(aBankAccountObj) method can then be used in turn to call the compareTo(aBankAccountObj) method and then finally return a boolean based on what compare To method returned The logic to compare two bankaccount objects and determine whether or not they are equal is left to your discretion and will be acceptable (b) Create an adapter BankAccountTester that will use the MyArrayBag class to create a bag object and manipulate it using BankAccount objects: i. Create a mix of CheckingAccount and Savings Account objects and add to the bag. You must have at least 4 BankAccount objects in the bag Print bag contents Hint: You will need to define print method to print data of bank accounts to console iii. Remove account(s), using both remove methods (random and a specified account) as defined in the interface ii. 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 object in your bag 3. In this section you will implement an ADT Bag using Linked Data. For that, create a class named MyLinkedBag that should also implement the same BagInterface that was implemented by your MyArrayBag class in Assignment-1. As a result, your MyLinkedBag class will have to implement all methods defined in the interface. [30 points] This class should: (a) Have a private instance variable called 'num Nodes', whose initial value should be 0. This variable will store an integer value, which will represent the count of node elements in the bag at any point in time (b) Have a default instance variable called 'firstNode' that will store a node object, which will be implemented through an inner class called 'Node', as outlined below. This variable will represent the starting node that can then be used to traverse through all other nodes in the bag (c) Have a no-arg constructor (d) Have the following methods: add(aBankAccount) i. This method should add a bankaccount object and return true to indicate if add was successful and false otherwise This method should take a bankaccount object as an argument This method will create a new Node object and set its data attribute to the bankaccount object object and set the next attribute of the new node to be what was previously firstNode and the firstNode attribute to this newly created node Note: - - The add method should handle both conditions, of adding a node to an empty bag, and also the case if the bag had node(s) prior to this addition ii. contains(aBankAccount) - This method should check to see if aBankAccount object exists in the bag The method should return true if the object exists and false otherwise Note: Keep in mind since the bankAccount object is stored as data within the linked node, you will need to traverse through the nodes and compare each node's data object to object coming in as argument to find the match 7 iii. remove() This method should delete the first node of the bag This method should return true if successful and false otherwise Note: Once the deletion is completed, the firstNode attribute should point to what was previously the node next to first node iv. remove(aBankAccount) This method deletes aBankAccount object in the bag This method should return true if successful and false otherwise Note: As in the case of contains method above, you will need to traverse through the nodes and compare each node's data to find the match As in the case of contains method above, you will need a way to compare two aBankAccount objects objects to check equality v. toArray() - - The method should return an array all aBankAccount objects in the bag Keep in mind that since bank account objects are stored as data within the linked nodes of the bag, you will need to traverse through the nodes within the bag and build the array of aBankAccount objects as retrieved from each node 4. Since you are creating MyLinkedBag class, you will not be using an array anymore to store objects. Instead, you will be creating a Node class, as inner class within your MyLinkedBag class, to facilitate storage and retrieval of stored objects [20 points] This Node inner class should: (a) Have an instance variable called 'data', that will store objects of type BankAccount (b) Have an instance variable called 'next', that will store a Node object, which represents the node next to current node (c) Have a no-arg constructor (d) Have a 1-arg constructor, that takes an object as an argument (e) Have a 2-arg constructor, that takes an object and Node object as two arguments. This constructor should set the object to the data attribute and Node object to the next node attribute of the current node, as discussed in class (f) Have getters and setters for each of the 2 instance variables for the class 5. Define an adapter class, BuildBag, for testing, whose main() method will contain the code to perform testing. The method should do the following [20 points] Along the lines of testing with bankaccount objects for the array-based bag, do the following to test your Linked Bag (a) Create 2 CheckingAccount and 2 SavingsAccount objects, with appropriate data. The data required to create the bank accounts can be hard-coded in the main() method (b) Instantiate your LinkedBag class, using the appropriate constructor(s) (c) Add the 4 bank account objects created above to the LinkedBag object using the add() method (d) Remove a bank account object from the bag (e) Print bag contents with details for each BankAccount in the bag
Expert Answer:
Answer rating: 100% (QA)
Below is the implementation of the BankAccount class and its subclasses SavingsAccount and CheckingAccount along with the MyLinkedBag class and an adapter class BuildBag for testing Please note that t... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Explain how to respond to and challenge discrimination in a way that promotes positive change.
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
Define a class Shares as an ADT that uses separate compilation (i.e separate interface and implementation files). The class represents shares for a shareholder in a specific company on the JSE. This...
-
how good are your with western civilization history?? choose one of the following topics topic 1: based on the texts by kafka and eliot, (writing on one or the other or both), discuss how the writers...
-
An unopened can of diet cola floats when placed in a tank of water, whereas a can of regular cola of the same brand sinks in the tank. What do you suppose could explain this behavior?
-
How will the Dodd-Frank Act affect value of structured instruments to both originator and issuer? Would it affect their usefulness as a source of financing and diversification/transfer of credit...
-
The following table summarizes visits to emergency departments at four hospitals in Arizona. People may leave without being seen by a physician, and those visits are denoted as LWBS. The remaining...
-
The Delmar Beverage Co. produces a premium root beer that is sold throughout its chain of restaurants in the Midwest. The company is currently producing 4,000 gallons of root beer per day, which...
-
What are the interesting objects you have learned about analyzing financial data? Which ratio would you relyon as an investor? as a business manager?
-
The following trial balance of Sergei Asbrecht Co. does not balance. Each of the listed accounts has a normal balance per the general ledger. An examination of the ledger and journal reveals the...
-
You are designing a three-group study to be evaluated with a one-way ANOVA at = .05. You expect effect size to be about .29. How many subjects will you need per group for .80 power?
-
For the system given below with the block diagram: a) Find the closed-loop transfer function C(s)/R(s) of the system when K = 0.025 and T = 10 seconds. b) By determining the natural frequency (w) and...
-
Required: Prepare the statement of profit or loss and other comprehensive income (by nature) and the statement of changes in equity for the year ended 31 October 2019 and statement of financial...
-
Based on the information provided pls answer the following questions: ? 1. What was the amount of total assets for RFC on December 31, 2013? 2. What was the amount of net income for RFC for fiscal...
-
q a alt N @ 2 - SHARK TANK WORKSHEET Business Ownership (Sales Presentations by Entrepreneurs to seek investors/partners) Be observant of the financial terms used during the Shark Tank Presentations...
-
Study problem-solving (decision- making) integrative case in the end of the textbook and prepare case study report following the four-step case study model introduced below.? Identifying problems...
-
Foot temperatures: Foot ulcers are a common problem for people with diabetes. Higher skin temperatures on the foot indicate an increased risk of ulcers. In a study performed at the Colorado School of...
-
9.Consider the reaction 3NO2(g)+H2O=2HNO3(aq)+NO(g) where Delta H=-137 kJ.How many kilojoules are released when 92.3g of NO2 reacts?
-
Mallory Corporation has a calendar year-end. The corporation has paid estimated payments of $10,000 during 2012 but still owes an additional $5,000 for its 2012 tax year. a. When is the 2012 tax...
-
Yolanda is a cash basis taxpayer with the following transactions during the year: Cash received from sales of products........................................................................$65,000...
-
During 2012, William purchases the following capital assets for use in his catering business: New passenger automobile (September 30)........................$21,500 Baking equipment (June 30)...
-
What is the difference between leading zeros and trailing zeros? Which ones are considered significant digits?
-
Explain the difference between number of digits, number of decimal places, and number of significant digits in a numerical value. Illustrate your explanation using the number 0.03720 .
-
What is the simplest way to convert a quantity given in one unit to the same quantity given in a different unit?
Study smarter with the SolutionInn App