Write a Console Application to create shape class & derive circle & rectangle from it to demonstrate the method over-riding concept
Module Module1
Class Shape
Public area As Double
Public color As String
Public Overridable Sub calcArea()
Console.WriteLine("inside the get area method of Shape class")
Console.WriteLine()
End Sub
Public Sub printArea()
Console.WriteLine("the area of the Shape is: " + area.ToString())
End Sub
End Class
Class Circle
Inherits Shape
Public radius As Double
Public Overrides Sub calcArea()
area = 3.1415 * radius * radius
End Sub
End Class
Class Rectangle
Inherits Shape
Public width As Double
Public height As Double
Public Overrides Sub calcArea()
area = width * height
End Sub
End Class
Sub Main()
Dim sap As New Shape
sap.calcArea()
Dim cir As New Circle
Console.Write("Enter the radius of circle :")
cir.radius = Convert.ToDouble(Console.ReadLine())
cir.calcArea()
cir.printArea()
Dim rect As New Rectangle
Console.Write("please enter the height of rectangle :")
rect.height = Convert.ToDouble(Console.ReadLine())
Console.Write("please enter the widht of rectangle :")
rect.width = Convert.ToDouble(Console.ReadLine())
rect.calcArea()
rect.printArea()
Console.ReadLine()
End Sub
End Module