In this exercise, you will write code to initialize the CAccount class. You will also implement the Authorize method of the CAccount class.
![]()
To see an example of how your code should look, click this icon.
![]()
The Authorize method will determine if a student has enough credit to purchase a book. It will look up a student's account balance in the StateUBookstore database. Students can owe the university a maximum of $500. If they have a balance including the book they are trying to buy of less than $500, the Authorize method will return True. If they are within $50 of their limit, they will be authorized, but the CAccount class will raise the Warning error to let students know they are close to their limit. If students are over their $500 limit, the Authorize method will return False.
| Parameter | Value |
|---|---|
| Source | "Select AccountBalance from Students Where StudentID = " & str(iStudentID) |
| ActiveConnection | cnStateUBookstore |
| CursorType | adOpenStatic |
| LockType | adLockReadOnly |
| Criteria | Result |
|---|---|
| Is <450 | The Authorize method returns True. |
| Is <= 499 | The Authorize method returns True and raises the Warning event because the student is within $50 of their $500 limit. |
| Is >= 500 | The Authorize method returns False and raises the Warning event that the student does not have enough available credit. |
| All other values | The Authorize method returns False. |
To see an example of how your code should look, click this icon.
To test the CAccount class, you may want to create a test procedure that creates an instance of the class, and calls the Authorize method for a student. Remember that you can use the Data View window to create a connection to the StateUBookstore database. With such a connection, you can open tables and evaluate the data to determine if your class is working correctly.