Lab Exercise 9 OOP (Inheritance And Polymorphism)

3
QUESTION 1 CODING FOR FORM: Public Class Form1 Dim obj As New Circle Dim r As Integer Dim h As Integer Private Sub btnCylinder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCylinder.Click With obj r = txtRadius.Text h = txtHeight.Text txtKeputusan.Text = Val((2 * 3.142) * r * h) End With End Sub Private Sub btnCircle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCircle.Click With obj r = txtRadius.Text h = txtHeight.Text txtKeputusan.Text = Val(3.142 * r * r) End With End Sub Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click With obj txtRadius.Text = "" txtHeight.Text = "" txtKeputusan.Text = "" End With End Sub Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub txtRadius_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtRadius.TextChanged End Sub Private Sub txtHeight_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtHeight.TextChanged

Transcript of Lab Exercise 9 OOP (Inheritance And Polymorphism)

Page 1: Lab Exercise 9 OOP (Inheritance And Polymorphism)

QUESTION 1

CODING FOR FORM:

Public Class Form1 Dim obj As New Circle Dim r As Integer Dim h As Integer

Private Sub btnCylinder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCylinder.Click With obj r = txtRadius.Text h = txtHeight.Text txtKeputusan.Text = Val((2 * 3.142) * r * h) End With End Sub

Private Sub btnCircle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCircle.Click With obj r = txtRadius.Text h = txtHeight.Text txtKeputusan.Text = Val(3.142 * r * r) End With End Sub

Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click With obj txtRadius.Text = "" txtHeight.Text = "" txtKeputusan.Text = ""

End With

End Sub

Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub txtRadius_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtRadius.TextChanged

End Sub

Private Sub txtHeight_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtHeight.TextChanged

End Sub

Private Sub txtKeputusan_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtKeputusan.TextChanged

End SubEnd Class

Page 2: Lab Exercise 9 OOP (Inheritance And Polymorphism)

INTERFACE OUTPUT: