Question
Hello, I need help with the following question, thank you for your help and for your time in advance The code should be in java
Hello,
I need help with the following question, thank you for your help and for your time in advance
The code should be in java
Write the code for a class Account with attribute balance, accessor methods, and method add(). Assume that Account has states Sound, Empty and Arrears, and that these are implemented using the State design pattern. Write a complete set of unit tests for Account, including state-oriented tests. The code should be in Java and comments in the source code should include descriptions of pre- and post-conditions of all implemented functions/methods
In Account, the code for add() is accountState().add().
In Arrears, the code for add() adds to the balance and replaces accountState by a Sound object is the balance is now non-negative. Keep in mind that the parameter is add() can be negative.
In Sound, the code for add() adds to the balance and replaces accountState if applicable.
State-oriented tests would transition among the states. An example is add 10, subtract 12, add 1, add 1, add 3.
Account and its States Acounts ate Account accountState add add0 Sound add0 Empty Arrears add0 add Account and its States Acounts ate Account accountState add add0 Sound add0 Empty Arrears add0 addStep 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