早教吧 育儿知识 作业答案 考试题库 百科 知识分享

VB总结类、对象、封装的含义(1)创建学生Student类,它包含三个属性:整型属性学号(NO)、字符型属性姓名(Name)、日期型属性生日(BirthDay),一个输出的方法PrintInformation,其中,输

题目详情
VB 总结类、对象、封装的含义
(1)创建学生Student类,它包含三个属性:整型属性学号(NO)、字符型属性姓名(Name)、日期型属性生日(BirthDay),一个输出的方法PrintInformation,其中,输出信息包含学号、姓名、生日。 (2)把1题中增加年龄(Age)属性,该属性只读,输出信息为:学号、姓名、年龄。 (3)把2题中定义一个构造函数,该构造函数可以包含(学号、姓名、生日)
▼优质解答
答案和解析
Public Class Students Dim intNo As Integer Dim strName As String Dim datBirthday As Date Public Structure StudentsInfo Dim NO As Integer Dim Name As String Dim Birthday As Date End Structure Public Sub New() intNo = 0 strName = "" datBirthday = Now End Sub Public Function PrintInformation() As StudentsInfo Dim stuInformation As StudentsInfo With stuInformation .NO = intNo .Name = strName .Birthday = datBirthday End With Return stuInformation End Function Public Property NO() Get Return intNo End Get Set(ByVal value) intNo = value End Set End Property Public Property Name() Get Return strName End Get Set(ByVal value) strName = value End Set End Property Public Property BirthDay() Get Return datBirthday End Get Set(ByVal value) datBirthday = value End Set End Property End Class Public Class StudentsAddAge Inherits Students Dim intAge As Integer Public Structure StudentsInfoAddAge Dim NO As Integer Dim Name As String Dim Age As Integer End Structure Public Sub New() intAge = 0 End Sub Public Property Age() Get Return intAge End Get Set(ByVal value) intAge = value End Set End Property Public Overloads Function PrintInformation(ByVal isPrintAge As Boolean) As StudentsInfoAddAge Dim stuInformation As StudentsInfoAddAge With stuInformation .NO = MyBase.NO .Name = MyBase.Name .Age = intAge End With Return stuInformation End Function End Class Public Class StudentsSubNew Inherits StudentsAddAge Public Sub New(ByVal NO As Integer, ByVal Name As String, ByVal BirthDay As Date) MyBase.NO = NO MyBase.Name = Name MyBase.BirthDay = BirthDay End Sub End Class
看了 VB总结类、对象、封装的含义...的网友还看了以下:

下面对信息属性的描述中,()中包含不恰当的成分;A.时效性、价值性、可扩散性B.准确性、传输性、共享  2020-05-23 …

下面对信息属性的描述中,()中包含不恰当的成分。A.时效性、价值性、可扩散性B.准确性、传输性、共享  2020-05-23 …

档案信息具有信息的一般属性,如中介性、 () 等。A.原始性B.可替代性C.可传输性D.可分享性  2020-05-31 …

下列有关说法正确的是()A.铜的金属活动性比铁弱,可以用铜罐代替铁罐盛装和运输浓硝酸B.明矾净水与  2020-07-24 …

下列关于男性生殖系统y说法,正确y是()A.男性的睾丸和附睾都可以产生精子B.尿道是排出精液与尿液  2020-08-03 …

下列说法不正确的是()A.Na是第三周期中金属性最强的元素B.Cl是第三周期中非金属性最强的元素C.  2020-11-02 …

(2004•南宁)钛(Ti是一种重要的航天金属材料.某学习小组对三种金属Ti、Al、Cu的金属活动性  2020-11-13 …

盐和金属反应,是按金属活动性顺序的规律进行的,非金属也有类似的性质,请根据下列三个反应,推断出Cl2  2020-12-07 …

男性生殖系统由多个生殖器官组成,下列属于男性生殖器官的是()。A.睾丸、输精管、前列腺B.睾丸、输精  2020-12-24 …

下列属于女性生殖器官的是()A.输卵管、阴茎、卵巢、阴道B.子宫、输卵管、卵巢、附睾C.输卵管、卵巢  2020-12-24 …