Thursday, April 6, 2017

1. Object Oriented Programming ( OOP ): Program code ( visual basic )

Computer Science(9608) notes and Resources








Sample Program code for Practise  #1 



Module Module1

    Class box

        Public length As Double
        Public breadth As Double
        Public height As Double

    End Class


    Sub Main()

        Dim box1 As box = New box()
        Dim box2 As box = New box()
        Dim volume As Double = 0

        box1.height = 5
        box1.length = 6
        box1.breadth = 7

        box2.height = 10
        box2.length = 12

        box2.breadth = 13

        volume = box1.breadth * box1.height * box1.length
        Console.WriteLine("volume of box 1: " & volume)


        volume = box2.breadth * box2.height * box2.length
        Console.WriteLine("volume of box 2: " & volume)

        Console.ReadKey()

    End Sub


End Module

No comments:

Post a Comment

Comments here....