Question: From the Topic 1 Class diagram assignment, write the BankAccount class in pseudocode. Use methods (getters and setters) to get and set the properties of

From the Topic 1 Class diagram assignment, write the BankAccount class in pseudocode.

Use methods (getters and setters) to get and set the properties of account id and holder name. Provide only a getter for account balance, not a setter, malfunctioning or malicious code could use a setter to set the balance inappropriately! To ensure our bank is following proper accounting practices, the only way to a balance can be modified is through credit (add) and debit (subtract) methods. If the debit method is called with an amount greater than the total balance, stop the transaction and output an insufficient funds message. It is also critical that no variables in the class can be accessed directly from outside of the class.

class BankAccount

Declarations

private string holderName

private num accountId

private num balance

public void setAccountNum(num tempAccNumber)

accountNum = tempAccNumber

return

public void setName(string tempName)

userName = tempUserName

return

public void setBalance(num tempBalance)

balance = tempBalance

return

public void displayAccount()

output Account number: , accountNum

output User Name: , name

output Balance: , balance

return

endClass

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!