Project 11 CECS277

$30.00

Category: Tags: , , , You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (4 votes)

Project11.zip should include project11 Package and project11.jar
Project11 package will include:
• Account.java
• AccountState.java
• RestrictedAccountState.java
• GoldAccountState.java
• NormalAccountState.java
• AccountStateDesignDemo.java→ has the client code (main method goes in here)
We are going to design our banking system to explore State design pattern.
Assume that we want to develop a banking system with these three kinds of different accounts.
Here are the scenarios
• If the balance in the account is greater than 0 and less than $20000 the status of the
account is normal(NormalAccountState). At this time, users can either deposit to the
account or withdraw money from the account. There is no interest gain for this account.
• If the balance in the account is less than or equal to 0. Then the status of the account is
Restricted(RestrictedAccountState). At this time, users can deposit but it can’t withdraw
money from the account. No interest for this account.
• If the balance in the account is equal or greater than $20000.00. Then the status of the
account is (GoldAccountState). At this time, the user can deposit into the account and can
withdraw money from the account. The interest will be calculated.
• According to different balances, the above three states can be converted to each other.
In these three states, NormalAccountState, RestrictedAccountState, and
GoldAccountState account, objects have different behaviors.
Method deposit() is used to deposit, withdraw() is used to withdraw money,
calculateInterest() is used to calculate interest, stateChangeCheck () is used to
determine whether to make a deposit or withdrawal operation according to the balance
after each deposit and withdrawal operation
The same method may have different implementations in different states.
Account.java
The account class combines an AccountState class, which is used to identify the status of the
current account. At the same time, when an operation request is made to an account, the
corresponding operation and permission restrictions are different according to different account
states. The implementation principle of making different operations according to different states
is polymorphism.
AccountState.java
abstract class of account status
In order to make the system more flexible and extensible, and encapsulate the common behavior in
each state, we need to abstract the state and introduce the role of abstract state class.
NormalAccountState.java
If the balance in the account is greater than 0 and less than $20000 the status of the account is
normal(NormalAccountState).
RestrictedAccountState.java
If the balance in the account is less than or equal to 0. Then the status of the account is
Restricted(RestrictedAccountState). At this time, users can deposit but it can’t withdraw money
from the account. No interest for this account.
GoldAccountState.java
If the balance in the account is equal or greater than to $20000.00. Then the status of the account
is (GoldAccountState). At this time, the user can deposit into the account and can withdraw
money from the account. The interest will be calculated by day. To calculate the interest, use hard
coded value of 0.01 over one year. The display value in the sample output is the monthly interest.

Sample Output: