hi all,in one of my interview the question paper was like this.

we need a banking system application which is having account types like saving account,current account and these account type having deposit,withdraw which are different for the account type,but the view account balance is same for the account type.you have to write a program with class structure with the minimum code and also keep in mind that later we can add account type that should not change your existing code.

so how to start this ?? urgent please

Dani AI

Generated

This is a standard design problem: separate the account contract (what every account must do) from concrete account types and from persistence. Note that VB6 has class modules but no class inheritance; polymorphism is achieved with an interface class plus Implements, and shared behavior is handled by delegation to a helper class. was right to suggest starting with a diagram and DB layout, and is correct that this is a common interview topic.

Minimal class layout (VB6 style)
Create an interface class IAccount (set to Not Creatable) and have concrete classes SavingsAccount, CurrentAccount implement it. Keep money in VB6 Currency.

' Class module: IAccount  (Not Creatable)
Public Function GetBalance() As Currency
End Function
Public Sub Deposit(ByVal amt As Currency)
End Sub
Public Sub Withdraw(ByVal amt As Currency)
End Sub
' Class module: SavingsAccount
Implements IAccount
Private mBalance As Currency
Private Function IAccount_GetBalance() As Currency
    IAccount_GetBalance = mBalance
End Function
Private Sub IAccount_Deposit(ByVal amt As Currency)
    mBalance = mBalance + amt
End Sub
Private Sub IAccount_Withdraw(ByVal amt As Currency)
    ' savings-specific rules
End Sub

Persistence and concurrency
Keep DB logic separate. Typical tables: Accounts(AccountID PK, AccountType, Balance DECIMAL(18,2), ...) and Transactions(TransactionID, AccountID FK, Amount, Type, Timestamp). Use stored procedures and SQL transactions to modify balance atomically. Example withdraw pattern:

BEGIN TRAN
UPDATE Accounts
 SET Balance = Balance - @amt
 WHERE AccountID = @id AND Balance >= @amt
IF @@ROWCOUNT = 0 ROLLBACK ELSE COMMIT

Extensibility and deployment
To add a new account type later, add a class that Implements IAccount and register it in the factory. For plugin-style extension, store a class ProgID in the DB and CreateObject it from an ActiveX DLL (classes must be published appropriately). Use Currency in VB6 and DECIMAL in SQL, parameterize DB calls, and keep business rules in the class layer with only persistence in the data layer. Starting with a small test harness and a UML sketch (per ) clarifies boundaries before coding.

Recommended Answers

All 6 Replies

You need to specify the following -

Which language to use i.e. vb6, .net etc...
What have you created thus far? We are not here to do your homework, only to help when you are stuck on a certain piece of code.
What database will you be using i.e. MySql, MsSQL, MsAccess etc..

If you have not started as yet, start with your diagram on how you will execute your code, what is needed in the application, what data needs to be saved + create database tables and fields, what kind of reports you would like to generate etc, etc.

Time to get the pen and paper out as vb5 likes to state.

Sorry to take your valuable time.i know how to write a program using vb 6.0.this program is for visual basic 6.0 and i am using sql server.

Ok, so what do you have so far for us. Have you created your database as yet? Have you started any coding so far? If yes, show us what you have and where we can help.

As it is an interview question, one that I have read before in another forum, I wonder if it was the OP that posted it in the other forum because the answers there were pretty good...

so can you please write a simple program in vb 6.0 which i have mentioned above ??
because i don't know how to initiate it and can we use class structure in vb 6.0 ??if yes then please help ??

Ibrahim, unfortunately we are not allowed by the rules and regulations of this site to do your homework for you, once we have done so, others will expect the same.
What worries me though is that you were given a task which must include a class structure (yes, it can be done in vb6), yet you do not even know where to start creating your application. I suggest you talk to your moderator and the other people in your group for solving this.

Yes, we do know how to do complete this task, we just can not and will not.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.