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.

Chapter 10 Object-Oriented <strong>Program</strong>ming: Polymorphism 413<br />

30 Set(ByVal salaryValue As Decimal)<br />

31<br />

32 ' validate mSalary<br />

33 If salaryValue > 0 Then<br />

34 mSalary = salaryValue<br />

35 End If<br />

36<br />

37 End Set<br />

38<br />

39 End Property ' Salary<br />

40<br />

41 ' property Commission<br />

42 Public Property Commission() As Decimal<br />

43<br />

44 Get<br />

45 Return mCommission<br />

46 End Get<br />

47<br />

48 Set(ByVal commissionValue As Decimal)<br />

49<br />

50 ' validate mCommission<br />

51 If commissionValue > 0 Then<br />

52 mCommission = commissionValue<br />

53 End If<br />

54<br />

55 End Set<br />

56<br />

57 End Property ' Commission<br />

58<br />

59 ' property Quantity<br />

60 Public Property Quantity() As Integer<br />

61<br />

62 Get<br />

63 Return mQuantity<br />

64 End Get<br />

65<br />

66 Set(ByVal QuantityValue As Integer)<br />

67<br />

68 ' validate mQuantity<br />

69 If QuantityValue > 0 Then<br />

70 mQuantity = QuantityValue<br />

71 End If<br />

72<br />

73 End Set<br />

74<br />

75 End Property ' Quantity<br />

76<br />

77 ' override method <strong>to</strong> calculate CommissionWorker earnings<br />

78 Public Overrides Function Earnings() As Decimal<br />

79 Return Salary + Commission * Quantity<br />

80 End Function ' Earnings<br />

81<br />

Fig. 10.11 CCommissionWorker class inherits from class CEmployee (part 2 of 3).

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

Saved successfully!

Ooh no, something went wrong!