30.07.2013 Views

Visual Basic.NET How to Program (PDF)

Visual Basic.NET How to Program (PDF)

Visual Basic.NET How to Program (PDF)

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

368 Object-Oriented <strong>Program</strong>ming: Inheritance Chapter 9<br />

14 ' get CCircle3's initial x-y coordinates and radius<br />

15 output = "X coordinate is " & circle.X & vbCrLf & _<br />

16 "Y coordinate is " & circle.Y & vbCrLf & "Radius is " & _<br />

17 circle.Radius<br />

18<br />

19 ' set CCircle3's x-y coordinates and radius <strong>to</strong> new values<br />

20 circle.X = 2<br />

21 circle.Y = 2<br />

22 circle.Radius = 4.25<br />

23<br />

24 ' display CCircle3's String representation<br />

25 output &= vbCrLf & vbCrLf & _<br />

26 "The new location and radius of circle are " & _<br />

27 vbCrLf & circle.ToString() & vbCrLf<br />

28<br />

29 ' display CCircle3's diameter<br />

30 output &= "Diameter is " & _<br />

31 String.Format("{0:F}", circle.Diameter()) & vbCrLf<br />

32<br />

33 ' display CCircle3's circumference<br />

34 output &= "Circumference is " & _<br />

35 String.Format("{0:F}", circle.Circumference()) & vbCrLf<br />

36<br />

37 ' display CCircle3's area<br />

38 output &= "Area is " & String.Format("{0:F}", circle.Area())<br />

39<br />

40 MessageBox.Show(output, "Demonstrating Class CCircle3")<br />

41 End Sub ' Main<br />

42<br />

43 End Module ' modCircleTest3<br />

Fig. 9.11 modCircleTest3 demonstrates class CCircle3 functionality<br />

(part 2 of 2).<br />

Software Engineering Observation 9.6<br />

Declaring base-class instance variables Private (as opposed <strong>to</strong> declaring them Protected)<br />

helps programmers change base-class implementation without having <strong>to</strong> change<br />

derived-class implementation. 9.6

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!