Aryan Choudhary
BCA-3A
Roll No-28
VB.net Assignment
Q1) Create a Base Class Employee. Create necessary functions for
Employee Class. Make two inherited classes Waged and Salaried
employee. Apply the concept of overloading, overriding for these
classes.
Code
Imports System
Class Employee
Public Name As String
Public Address As String
Public age As Integer
Public Gender As String
Sub CallPrint()
Print()
End Sub
Sub CallMyClassPrint()
MyClass.Print()
End Sub
Overridable Sub Print()
Console.WriteLine(vbTab & Name)
Console.WriteLine(vbTab & Address)
Console.WriteLine(vbTab & age)
Console.WriteLine(vbTab & Gender)
End Sub
End Class
Class waged_Employee
Inherits Employee
Public wage As Integer
Public hours As Integer
Aryan Choudhary
BCA-3A
Roll No-28
Overrides Sub Print()
Console.WriteLine(vbTab & Name)
Console.WriteLine(vbTab & Address)
Console.WriteLine(vbTab & age)
Console.WriteLine(vbTab & Gender)
Console.WriteLine(vbTab & "Wage = " & wage)
Console.WriteLine(vbTab & "Daily Worked hours : " & hours)
End Sub
End Class
Class salaried_Employee
Inherits Employee
Public Salary As Integer
Public hours As Integer
Overrides Sub Print()
Console.WriteLine(vbTab & Name)
Console.WriteLine(vbTab & Address)
Console.WriteLine(vbTab & age)
Console.WriteLine(vbTab & Gender)
Console.WriteLine(vbTab & "Daily Worked hours : " & hours)
Console.WriteLine(vbTab & "Salary = " & Salary)
End Sub
End Class
Module Test
Sub Main()
Dim a As waged_Employee = New waged_Employee()
Dim b As salaried_Employee = New salaried_Employee()
Dim e1 As Employee
Dim e2 As Employee
a.Name = "Parmeet Singh"
a.Address = "Delhi Cantt"
a.age = 25
a.Gender = "male"
a.wage = 30000
a.hours = 10
b.Name = "Priya Gargh"
b.Address = "Faridabad"
b.age = 26
b.Gender = "Female"
Aryan Choudhary
BCA-3A
Roll No-28
b.Salary = 50000
b.hours = 9
e1 = a
e2 = b
Console.WriteLine(vbTab & vbTab & "* Employee Info *")
e1.CallMyClassPrint()
Console.WriteLine()
Console.WriteLine(vbTab & vbTab & "* Employee All Detail *")
e1.CallPrint()
Console.WriteLine()
Console.WriteLine()
Console.WriteLine(vbTab & vbTab & "* Employee Info *")
e2.CallMyClassPrint()
Console.WriteLine()
Console.WriteLine(vbTab & vbTab & "* Employee All Detail *")
e2.CallPrint()
End Sub
End Module
Output
Aryan Choudhary
BCA-3A
Roll No-28
Aryan Choudhary
BCA-3A
Roll No-28
Q2) Implement below Library management system in console.
Aryan Choudhary
BCA-3A
Roll No-28
Q3) Write a program to show the use of Constructors, Destructors
and interfaces in VB.net.
Code
Imports System
Module moddule1
Interface calculator
Sub calculate()
End Interface
Class addition
Implements calculator
Private val1 As Integer, val2 As Integer
Public Sub New(ByVal a As Integer, ByVal b As Integer)
val1 = a
val2 = b
Console.WriteLine("1st Numbers : " & a)
Console.WriteLine("2nd Numbers : " & b)
Console.WriteLine()
End Sub
Public Sub calculate() Implements calculator.calculate
Console.WriteLine("* Calulate function called from Addition Class *")
Dim result As Integer
result = val1 + val2
Console.WriteLine("Addition Result : " & result)
Console.WriteLine()
Console.WriteLine()
End Sub
Protected Overrides Sub Finalize()
Console.WriteLine("An Instance of Addition class destroyed")
End Sub
End Class
Class subtraction
Implements calculator
Private val1 As Integer, val2 As Integer
Public Sub New(ByVal a As Integer, ByVal b As Integer)
val1 = a
val2 = b
End Sub
Public Sub calculate() Implements calculator.calculate
Console.WriteLine("* Calulate function called from Subtraction Class *")
Dim result As Integer
result = val1 - val2
Aryan Choudhary
BCA-3A
Roll No-28
Console.WriteLine("Subtraction Result : " & result)
End Sub
Protected Overrides Sub Finalize()
Console.WriteLine("An Instance of Subtraction class destroyed")
End Sub
End Class
Public Sub Main(ByVal args As String())
Dim cal1 As calculator = New addition(55, 43)
Dim cal2 As calculator = New subtraction(55, 43)
cal1.calculate()
cal2.calculate()
End Sub
End Module
Output