subject

Objectives:
junit testing
collections: set
logic exception handling
getting started
to begin this lab, create a new java project named abc123-lab7, and create the following packages and classes:
bank. account. java
bank. bank. java
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);
junit testing
create a junit 4 test case, called accounttest. java. this class will test only the functionality in the account class, defined above. implement the following methods:
setup() - method runs before each test is run.
testinit() - test the constructors.
testvaliddeposit() - test depositing a valid amount (i. e. positive amount) into the account.
testinvaliddeposit() - test depositing an invalid amount (i. e. negative amount) into the account.
testvalidwithdrawl() - test withdrawing a valid amount (i. e. positive amount) from the account.
testinvalidwithdrawl() - test withdrawing an invalid amount (i. e. negative amount) from the account.
testoverdraft() - test withdrawing more than the balance from the account.
no test methods should be created for the getters or setters in the account class. each method should have the appropriate junit annotation. overdrafts should not be permitted, instead a message must be presented to the user. for each test listed, consider the preconditions and postconditions of the method in testing. consider any input (parameters), logical requirements (described in the class descriptions above), and outputs (returned values). what could go wrong when the method is called? equally important, what could be wrong after the method is called?
in the process of implementing these tests, you should run them and verify they are passing. if a test does not pass, first assess the test (is it set up then verify your implementation meets the requirements (see account. java above). a completed submission for this lab will correctly assess all test cases, and running accounttest. java will result in a pass (green bar in the junit view).
note that your submitted eclipse project must include the dependecy for junit 4. to ensure this, export your code from eclipse to an archive file, as in the lab instructions!
unsure about a test or implementation?
imagine you are writing code for your bank. how do you want your money to be handled? if you were to try to deposit or withdraw an invalid amount of money, would you want your account balances to be affected? would you want to be warned of the error?

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 15:00
The three logical operators used to write compound conditions are "and," "or," and "not." a: true b: false
Answers: 2
question
Computers and Technology, 23.06.2019 12:00
Using the list, you can select the number of photos that will appear on each slide. a. theme b. frame shape c. pictures in album d. picture layout
Answers: 1
question
Computers and Technology, 24.06.2019 07:40
What type of multimedia are live news feeds? live news feeds are examples of multimedia.
Answers: 2
question
Computers and Technology, 24.06.2019 11:20
Print "censored" if userinput contains the word "darn", else print userinput. end with newline. ex: if userinput is "that darn cat.", then output is: censoredex: if userinput is "dang, that was scary! ", then output is: dang, that was scary! note: if the submitted code has an out-of-range access, the system will stop running the code after a few seconds, and report "program end never reached." the system doesn't print the test case that caused the reported message.#include #include using namespace std; int main() {string userinput; getline(cin, userinput); int ispresent = userinput.find("darn"); if (ispresent > 0){cout < < "censored" < < endl; /* your solution goes here */return 0; }
Answers: 3
You know the right answer?
Objectives:
junit testing
collections: set
logic exception handling
gettin...
Questions
question
Biology, 29.09.2019 02:30
question
Physics, 29.09.2019 02:30