ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

VB.NET Ãþ§O³W¹º Ä~©Ó OverLoading

VB.NET Ãþ§O³W¹º Ä~©Ó OverLoading

OverLoading ¦h¸ü °Ñ¼Æ¼Æ¶q¤£¤@¼Ë ©Î ¬Û¦P°Ñ¼Æ¼Æ¶q¦ý§ÎºA¤£¤@¼Ë

¤÷Ãþ§O Employee



¤lÃþ§O Sales



¥Dµ{¦¡

Module TestSales  

02     '¥Dµ{¦¡  

03     Public Sub Main()  

04         '©w¸q°Ï°ìÅܼƠ 

05         Dim s As Sales = New Sales() '¹w³]«Øºc¤l  

06         s.Id = "0001"

07         s.Name = "eric"

08         s.Salary = 20000  

09         s.Qa = 50000  

10         System.Console.WriteLine(s.Name)  

11         'ºâ·~ÁZ  

12         's.calBon(60000)  

13         'Á~¸ê­pºâ(©I¥s¨ìEmployee)  

14         Dim sal As Decimal = s.calSalary()  

15         System.Console.WriteLine(s.Salary)  

16         '©I¥s¥t¤@­Ó§t·~ÁZ¼úª÷ªº  

17         s.calSalary(60000)  

18   

19         System.Console.WriteLine(s.Salary)  

20   

21     End Sub

22 End Module
view sourceprint?01 '«ü©wÄ~©Ó¨Ó·½(Parent Class) «DÃö©R¦WªÅ¶¡  

02 Imports mod06.Domain.IT  

03 Public Class Sales  

04     Inherits Employee '³æ¤@Ä~©Ó(¤÷¿Ë¥u¯à¤@­Ó)  

05     'Data Field  

06     '·~ÁZ  

07     Private _qa As Decimal

08     Private _bon As Decimal '¼úª÷  

09   

10     'ÄÝ©Ê  

11     ''' <summary>  

12     ''' ³]©w©ÎªÌ¨ú±o·~ÁZ  

13     ''' </summary>  

14     ''' <value>·~ÁZª÷ÃB</value>  

15     ''' <returns>·~ÁZª÷ÃB</returns>  

16     ''' <remarks></remarks>  

17     Public Property Qa() As Decimal

18         Get

19             Return Me._qa  

20         End Get

21         Set(ByVal value As Decimal)  

22             If (value > 0) Then

23                 Me._qa = value  

24             End If

25         End Set

26     End Property

27     '°ßŪÄÝ©Ê  

28     Public ReadOnly Property Bon() As Decimal

29         Get

30             Return Me._bon  

31         End Get

32     End Property

33     'Method°Ó·~³W«hBusiness Rules ¼úª÷­pºâ³¡¤À  

34     Public Sub calBon(ByVal act As Decimal)  

35         If (act >= Me._qa) Then

36             Me._bon = act * 0.05  

37         End If

38     End Sub

39     '¦P®É­pºâ¼úª÷»PÁ~¸ê  

40     Public Overloads Sub calSalary(ByVal act As Decimal)  

41         If (act >= Me._qa) Then

42             Me._bon = act * 0.05  

43             '©³Á~_salary¥[¦^¼úª÷  

44             _salary += Me._bon  

45         End If

46   

47     End Sub

48 End Class
view sourceprint?01 Namespace Domain.IT  

02     'public Modifier­×¹¢µü-¥i¨£«×  

03     '½sĶ²£¥Í¤÷Ãþ§O¬°System.Object  

04     Public Class Employee  

05         'Ãþ§O¼h¯ÅÅܼÆ(Data Field)  

06         Private _id As String

07         Private _name As String

08         '¹ê²{«Ê¸Ë¯S©Ê(private ¨p¥Î -¥i¨£«×­­³o¤@­ÓÃþ§O¤º)  

09         '§ï¦¨protected ª«¥ó«Ê¸Ë©Ê ¤lÃþ§O¤£«Ê¸Ë   

10         Protected _salary As Decimal

11         Private _birthDate As DateTime  

12         Private _sex As String

13         ' ½sĶ²£¥Í¹w³]«Øºc¤l ªÅ°Ñ¼Æ  

14   

15   

16         'Äݩʦs¨ú(µ{§Ç)  

17         Public Property Salary() As Decimal

18             Get

19                 Return _salary  

20             End Get

21             Set(ByVal value As Decimal)  

22                 If (value > 0) Then

23                     _salary = value  

24                 End If

25             End Set

26         End Property

27   

28         Public Property Id() As String

29             Get

30                 Return Me._id  

31             End Get

32             Set(ByVal value As String)  

33                 Me._id = value  

34   

35             End Set

36         End Property

37   

38         Public Property Name() As String

39             Get

40                 Return Me._name  

41             End Get

42             Set(ByVal value As String)  

43                 Me._name = value  

44             End Set

45         End Property

46   

47         Public Property BirthDate() As DateTime  

48             Get

49                 Return Me._birthDate  

50             End Get

51             Set(ByVal value As DateTime)  

52                 If (value <= System.DateTime.Now) Then

53                     Me._birthDate = value  

54                 End If

55             End Set

56         End Property

57   

58         Public Property Sex() As String

59             Get

60                 Return Me._sex  

61             End Get

62             Set(ByVal value As String)  

63                 Me._sex = value  

64             End Set

65         End Property

66   

67   

68         'Á~¸ê­pºâªº¥\¯àMethod  

69         '©wµ²ºc «DÃö²Ó³¡¾Þ§@  

70         Public Overloads Function calSalary() As Decimal

71             Return Me._salary  

72         End Function

73     End Class

74 End Namespace
­Ó¤Hñ¦W@

        ÀR«ä¦Û¦b : ¦³Ä@©ñ¦b¤ß¸Ì¡A¨S¦³¨­Åé¤O¦æ¡A¥¿¦p¯Ñ¥Ð¤£¼½ºØ¡A¬Ò¬OªÅ¹L¦]½t¡C
ªð¦^¦Cªí ¤W¤@¥DÃD