类的概念(1)

'类的概念(1)
 
Module Module1
    Sub Main()
 
    End Sub
 
    Public Class Car
        '成员变量
        Private _Color As String = "红色"   '车身颜色
        Private _WheelCount As Short = 4    '轮胎数
        Private _ChairCount As Short = 5    '座椅数
        Private _RunCount As Integer = 0    '行驶公里数   
        Private _RunAble As Boolean = True  '可行驶状态
 
        '属性:颜色
        Public Property Color() As String
            Get
                Return _Color   '返回属性值
            End Get
            Set(ByVal Value As String)
                _Color = Value  '属性赋值
            End Set
        End Property
 
        '轮子的数目
        Public ReadOnly Property WheelCount() As Short
            Get
                Return _WheelCount
            End Get
        End Property
 
        '座椅的数目
        Public Property ChairCount() As Short
            Get
                Return _ChairCount
            End Get
            Set(ByVal Value As Short)
                _ChairCount = Value
            End Set
        End Property
 
        '已行驶公里数
        Public Property RunCount() As Integer
            Get
                Return _RunCount
            End Get
            Set(ByVal Value As Integer)
                _RunCount = Value
            End Set
        End Property
 
        '可行驶状态
        Public Property RunAble() As Boolean
            Get
                Return _RunAble
            End Get
            Set(ByVal Value As Boolean)
                _RunAble = Value
            End Set
        End Property
 
        '方法:汽车开动
        Public Sub Go()
            Console.WriteLine("嘀嘀嘀... ...")
        End Sub
 
        '构造方法
        Sub New()
            _Color = "米色"
        End Sub
 
    End Class
End Module
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值