Part 1

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:

  • This property is Read-only.
  • Amounts withdrawn or deposited into the account affect the balance, using the Deposit and Withdraw method below.

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.

Part 2

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

Part 3

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

Part 4

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

Part 5

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

Part 6

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.

Part 7

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..

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.