Write code to create a class definition for Account. These are the needed specs for the class.
1.There is only one constructor for this class that receives two strings: firstname, and lastname. The values of these strings will be passed from the client code. See below for what to do with these strings. An account starts with a $100 balance (see Balance property below).
2.ID. During creation (inside sub new), the ID value is made of the user's first name followed by the underscore followed by the last name, for example if passed "John" and Smith, the ID value is John_Smith ID is a string property that is read-only.
3.Password. During creation the value for password the same as the ID with the added string "Change". Afterwards, the password may not be "displayed" to the client. However, client may change the password, using ChangePassword method below. This makes password aWrite-only property. To force the end user to change their password before using their account, a boolean variable, PasswordReset, is set to true under Sub New. This variable is to changed false under the ChangePassword method below.
4.An account Balance is a number with fractions:
Account has the following methods:
1.Deposit which takes two arguments, an amount (to be deposited as a number with fractions), and password (a string). If PasswordReset is False, then check if the password passed matches the account password then the actions below are possible, otherwise an error message is shown. If PasswordReset is True issue an error message to change the password first.
If the amount passed is > 0 then add it to the current balance (recall Balance is read-only), otherwise another error message is shown.
2.Withdraw which takes two arguments, an amount (to be withdrawn as a number with fractions), and password (a string).
The logic to withdraw is the same as the logic to Deposit, except that we must additionally check if the withdrawal will cause the balance to be negative), then no withdrawal is possible. Issue an error message (make sure the balance is not changed). Otherwise f the amount passed is > 0 then deduct from the current balance (recall Balance is read-only), otherwise another error message is shown.
3.ChangePassword is a method that takes two string, current password and a new password, if the current password matches the account password, change the account password to the new password, and issue a message, otherwise issue an error message.
Now we work on the client code.
On the user form, there are 2 textboxes txtFname, and txtLname, and a button btnCreate.
There are also, a textbox, txtAmount, and 2 buttons, btnWithdraw, and btnDeposit.
Make sure your code below uses the exact control names shown above.
In all the code below, no data validation is required (i.e. assume the user will type a number when expected, and a string when expected).
Also assume in all the code below that an object named MyAccount has been declared (declared only) as an Account as a form (global) level variable.
Write the code needed so that when the user Clicks btnCreate, MyAccount is created based on account with an id whose values are passed in txtFname (for the first name), and txtLname (for the last name). Then erase the content of all textboxes.
Sub CreateAccount(...,...) Handles btnCreate.Click
End Sub
Write code to activate the account which calls the PasswordReset method. Use the two textboxes to pass the current and new password. Assume the following button handler:
Sub ResetPass(...,...) Handles btnResetPass.Click
End Sub
Using the same form and controls, write code for btnWithdraw so when the user types a number in txtAmount and clicks btnWithdraw, the account withdraw method is called on the amount in txtAmount, and the password entered into the second textbox.
Clear both textboxes.
Show the new balance in a messagebox.
Sub withdraw(...,...) Handles btnWithdraw.Click
End Sub
Same as in the previous question, write code for btnDeposit so when the user types a number in txtAmount and the password in the second textbox then clicks btnDeposit, the account Deposit method is called on the amount in txtAmount, and the password from the second textbox.
Clear the textboxes. Show the new balance in a messagebox.
Sub deposit(...,...) Handles btnDeposit.Click
End Sub
Update the code you wrote for the Account class
The Account class need to issue a warning (using an Event) so that when the Balance becomes $10 or less, the client is warned.
In this answer you will only write the code for the Account class. You may add comments to explain where the newly added code goes. Limit your comments to a short one line sentence.
Now (re)write the code that declares an object that will later be created to represent the account class. This object will handle event statically.
Add any code and show where this code goes, so that the object is able to handle events statically.
Also write an event handler for the event required in the question above, so that when the event occurs:
In one messagebox show the balance to the user and tell them they should deposit money into the account..