hierarchical inheritance for banking operation

Posted by Shreesh under VB.NET on 10/3/2011 | Points: 10 | Views : 3467 | Status : [Member] | Replies : 4
hi,i'm workin on a console application that uses the hierarchical inheritance for banking operation i.e account creation,deposit,withdraw and balance.

i've written the following code but don't know what's wrong with it.. it says "'dep' is not a member of 'ConsoleApplication1.Module1.withdraw'".
this is the code!

"

Public Class creation
Dim name As String
Dim address As String
Dim phone As Integer
Public amt As Integer
Public wd As Integer
Public bal As Integer

Sub display()
name = Console.ReadLine()
address = Console.ReadLine()
phone = Console.ReadLine()
End Sub
Sub print()
Console.WriteLine(name)
Console.WriteLine(address)
Console.WriteLine(phone)
End Sub
End Class

Public Class deposit
Inherits creation
Sub dep()
Console.WriteLine("enter the amt to be deposited:")
amt = Console.ReadLine()
Console.WriteLine("the amt deposited is ", amt)
End Sub
End Class

Public Class withdraw
Inherits creation
Sub withd()
Console.WriteLine("enter the amt to withdraw fro ur account")
wd = Console.ReadLine()
bal = amt - wd
Console.WriteLine("the bal is ", bal)
End Sub
End Class

Sub Main()
Dim ob As New withdraw
ob.display()
ob.print()
ob.dep()
ob.withd()
End Sub




Responses

Posted by: Ndebata on: 10/4/2011 [Member] Starter | Points: 25

Up
0
Down
You can not access it from withdraw object as it is defined in Deposit class
Sub Main()

Dim ob As New withdraw
ob.display()
ob.print()
ob.dep()

ob.withd()
End Sub


Shreesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vishvvas on: 10/5/2011 [Member] [MVP] HonoraryPlatinum | Points: 25

Up
0
Down
Try following, in the withdraw class define following
Sub dep()
MyBase.dep()
End Sub
*************
Hope this helps.

Shreesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ndebata on: 10/5/2011 [Member] Starter | Points: 25

Up
0
Down
@Vishvvas base does not have method called dep(), he has to write it first.

Shreesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vishvvas on: 10/5/2011 [Member] [MVP] HonoraryPlatinum | Points: 25

Up
0
Down
My bad, I assumed that Withdraw inherits from deposit. Yes, to have this method work, either it be defined in Withdraw or WIthdraw needs to inherit from Deposit

Shreesh, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response