Skip to content

Commit

Permalink
Merge pull request #139 from Vavinan/fix-dg-edit-and-remove
Browse files Browse the repository at this point in the history
Fix dg edit and remove
  • Loading branch information
Vavinan committed Apr 11, 2024
2 parents 6023ea2 + ac39076 commit ec4b238
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 42 deletions.
63 changes: 41 additions & 22 deletions docs/uml/processEditTransactionDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,46 @@
autonumber

actor User
participant "TransactionManager" as TM
participant "TransactionList" as TL
participant "UserInterface" as UI
participant "AccountManager" as AM
participant "Parser" as P
participant ":AccountManager" as AM
participant ":Parser" as P
participant "EmptyArgumentException" as EAE
participant "InvalidIndexException" as IIE
participant "NumberFormatException" as NFE
User -> TL: editTransaction [edit index]

User -> TM: editTransaction [edit index]
TM -> UI: getEditInformation(transaction)
activate UI
UI --> TM: newTransaction
deactivate UI
TM -> P: parseEditTransaction(newTransaction, account)
activate P
P --> TM: updatedTransaction
deactivate P
TM -> AM: getAccountByAccountNumber(accountNumber)
activate AM
AM --> TM: account
deactivate AM
TM -> TM: setTransaction(updatedTransaction)
TM -> UI: printUpdatedTransaction(updatedTransaction)
activate UI
UI --> User: Display updated transaction
deactivate UI
@enduml
alt edit index is empty
TL -> EAE: throw EmptyArgumentException("edit index")
end
alt index is not an integer
TL -> NFE : throw NumberFormatException(edit_index)
end
TL -> TL: index = parseInt(data)
alt index is within bounds
TL -> UI: <getEditInformation(transaction)>
activate UI
UI --> TL: newTransaction
deactivate UI
TL -> P: parseEditTransaction(newTransaction, account)
activate P
P --> TL: updatedTransaction
deactivate P

TL -> AM: getAccountByAccountNumber(accountNumber)
activate AM
AM --> TL: account
deactivate AM

TL -> TL: setTransaction(updatedTransaction)

TL -> UI: <printUpdatedTransaction(updatedTransaction)>
activate UI
UI --> TL: Display updated transaction
deactivate UI
TL --> User: Display Output
else
TL -> IIE: throw InvalidIndexException(transaction_list_size)
end

@enduml
39 changes: 19 additions & 20 deletions docs/uml/removeTransactionDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,35 @@
autonumber

actor User
participant "TransactionManager" as TM
participant "TransactionList" as TL
participant "UserInterface" as UI
participant ":AccountManager" as AM
participant ":Account" as AC
participant "EmptyArgumentException" as EAE
participant "InvalidIndexException" as IIE
User -> TM: removeTransaction [delete index]
User -> TL: removeTransaction [delete index]

alt input.trim().length() >= DELETE_BEGIN_INDEX
TM -> TM: parseData(data)
TM -> AM: getAccountByAccountNumber(accountNumber)
activate AM
AM --> TM: :Account
deactivate AM

TM -> TM: getTransaction(id)
TM -> TM: removeTransaction(id)
alt input.trim().length() < DELETE_BEGIN_INDEX
TL -> EAE: throw EmptyArgumentException
end
TL -> TL: id = parseInt(data)
alt id >= LOWER_BOUND and id < size
TL -> AM: getAccountByAccountNumber(accountNumber)
activate AM
AM --> TL: :Account
deactivate AM

TM -> AC: setBalance(newBalance)
TL -> TL: get(id)
TL -> TL: remove(id)

alt id >= LOWER_BOUND and id < size
TM -> UI: printDeleteMessage(itemRemoved, newBalance)
TL -> AC: setBalance(newBalance)
TL -> UI: <printDeleteMessage(itemRemoved, newBalance)>
activate UI
UI --> TM: Display delete confirmation message
UI --> TL: Display delete confirmation message
deactivate UI
TM --> User: Confirmation message
TL --> User: Confirmation message
else
TM -> IIE: throw InvalidIndexException
end
else
TM -> EAE: throw EmptyArgumentException
TL -> IIE: throw InvalidIndexException
end

@enduml
Binary file modified docs/uml/uml-images/processEditTransactionDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/uml/uml-images/removeTransactionDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ec4b238

Please sign in to comment.