Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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 add

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions