Question
This lab does not deal with synchronized or multithreading. Correct solutions to this lab may not be thread-safe. Banks & Accounts Bank.java will define functionality
This lab does not deal with synchronized or multithreading. Correct solutions to this lab may not be thread-safe.
Banks & Accounts
Bank.java will define functionality for a bank. Banks must have a name and a set of accounts. Use a java.util.Set implementation of your choosing for this data structure, and the Account.java implementation for the accounts stored. Bank.java must have a single constructor to properly initialize banks. In addition, there should be an overloaded method called addAccount which can add Account objects to the bank given either a name for the account, or both a name for the account and a starting balance. This method will create an Account object and add it to the set stored in the Bank object, nothing will be returned. Creating a new object would be as follows: Bank bank = new Bank("Gringotts");
Account.java will define functionality for an account. Accounts must have a name associated with them, an account number, and a balance. As described above, an Account object can be defined using either all three of these (name, number, and balance) or only with the name and number. (This indicates the constructor must be overloaded - one for each of these cases.) If a starting balance is not provided, it will be assumed to be 0. There should be getters and setters for all of these three variables. Account.java must have two additional methods: deposit and withdraw. deposit will be an object method that takes in an amount of money and adds the amount to the balance of an account. Deposits should inherently only the positive values. This method will return the new balance of the account. withdraw will be an object method that takes in an amount of money and reduces the balance by that amount. Withdrawls should inherently only be positive values. Withdrawls larger than the current balance should not be permitted. This method will return the new balance of the account. Creating a new object would be as follows: Account account1 = new Account("Amy Smith", 2202); or Account account2 = new Account("Bob Smith", 1584, 100.0);
Step 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