Help Needed With OOP Bank Account..VB.Net

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2007
Posts: 3
Reputation: iseedeadpixels is an unknown quantity at this point 
Solved Threads: 0
iseedeadpixels iseedeadpixels is offline Offline
Newbie Poster

Help Needed With OOP Bank Account..VB.Net

 
0
  #1
Oct 24th, 2007
Hi everyone!

At the moment I am working on an OOP bank account program as an assignment in VB.Net.

FYI:It has a credit account class with properties of AccountName, AccountNumber and Balance. The credit account class has two methods - deposit and withdraw. You can overdraw on the credit account, but not on the savings account. If the user tries to overdraw on the savings account, a user defined event displays an error message.

I think I've written the Credit Account and Savings Account classes correctly, but what I'm getting stuck with is the user defined event to display the error message, and I'm getting confused when I try to get it all to work off my GUI. Some buttons and functions work while others kinda don't ...and I'm losing so much sleep over it and it's probably something really minor (to you lol) My interface consists of textboxes(AccName, AccNum & Amount to specify the amount you deposit or withdraw) Radio Buttons (Credit & Savings to choose account type. Deposit & Withdraw to choose transaction) Buttons (Clear, Confirm, Exit) Again, any help, tips, pointers, links or anything that would help or point me in the right direction would be greatly appreciated. Thank you
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,273
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 378
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Help Needed With OOP Bank Account..VB.Net

 
0
  #2
Oct 24th, 2007
Well how can we diagnose the problem without seeing the code. Post it here!
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 3
Reputation: iseedeadpixels is an unknown quantity at this point 
Solved Threads: 0
iseedeadpixels iseedeadpixels is offline Offline
Newbie Poster

Re: Help Needed With OOP Bank Account..VB.Net

 
0
  #3
Oct 24th, 2007
Hi everyone!

Yeah sorry about that...maybe posting the code would be a good idea huh?! lol

Sooooo sorry if I post it wrong...

First Class - Credit Account

  1. Public Class Credit_Account
  2.  
  3. Private AccountName As String 'Customer's Account Name
  4. Private AccountNumber As Integer 'Customer's Account Number
  5. Protected Balance As Double 'Customer's Account Balance
  6.  
  7. Public Sub New(ByVal Nm As String, ByVal Bal As Double)
  8. AccountName = Nm
  9. Balance = Bal
  10. End Sub
  11.  
  12. Property AccName() As String
  13. Get
  14. Return AccountName
  15. End Get
  16. Set(ByVal Value As String)
  17. AccountName = Value
  18. End Set
  19. End Property
  20.  
  21. Property AccNumber() As Integer
  22. Get
  23. Return AccountNumber
  24. End Get
  25. Set(ByVal Value As Integer)
  26. AccountNumber = Value
  27. End Set
  28. End Property
  29.  
  30. ReadOnly Property AccountBal() As Double
  31. Get
  32. Return Balance
  33. End Get
  34. End Property
  35.  
  36. Public Overridable Sub Deposit(ByVal Amount As Double)
  37. Balance += Amount
  38. End Sub
  39.  
  40. Public Overridable Sub Withdraw(ByVal Amount As Double)
  41. Balance -= Amount
  42. End Sub
  43. Public Overridable Sub Display()
  44. Console.WriteLine("Name=" & AccountName & ", " & "Balance=" & Balance)
  45. End Sub
  46.  
  47. Public Sub ChangeName(ByVal newName As String)
  48. AccountName = newName
  49. End Sub
  50. ' Initial balance is zero for each new instance
  51. Public Sub New()
  52. Balance = 0
  53. End Sub
  54. End Class

Second Class - Savings Account

  1. Public Class Saving_Account
  2. Inherits Credit_Account
  3.  
  4. Public Sub New(ByVal Nm As String, _
  5. ByVal Bal As Double)
  6.  
  7. MyBase.New(Nm, Bal)
  8.  
  9. End Sub
  10. Public Overrides Sub Withdraw(ByVal Amount As Double)
  11. If Amount <= Balance Then ' Use balance, inherited from base class
  12. MyBase.Withdraw(Amount) ' Call Withdraw, inherited from base class
  13. End If
  14. End Sub
  15.  
  16. Public Overrides Sub Display()
  17. MyBase.Display() ' Call Display, inherited from base class
  18. Console.WriteLine("There are insufficient funds to complete this transaction." & vbCrLf _
  19. & "This account cannot have a negative balance.", "Transaction Error")
  20. End Sub
  21. End Class

Then like I said above, I have my form with buttons, radio buttons and textboxes...I have some code written for my form, but it's all messed up so I thought I'd better not post it

I'm unsure of where the RaiseEvent code is supposed to go to "Raise the user defined error message when the user tries to overdraw on the savings account"...and any hints on what I should be trying to write on my 'Confirm' button, on my form to get everything to work that would be cool...so far, when you click on it, it just deposits money into the credit account and shows the running balance. I'm working on the data validation part but again, some parts don't go while some parts do???!!!! AAAAAAAAAARGH....

Thanks for taking the time to give me some much needed advice...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 2790 | Replies: 2
Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC