早教吧作业答案频道 -->其他-->
VB总结类、对象、封装的含义(1)创建学生Student类,它包含三个属性:整型属性学号(NO)、字符型属性姓名(Name)、日期型属性生日(BirthDay),一个输出的方法PrintInformation,其中,输
题目详情
VB 总结类、对象、封装的含义
(1)创建学生Student类,它包含三个属性:整型属性学号(NO)、字符型属性姓名(Name)、日期型属性生日(BirthDay),一个输出的方法PrintInformation,其中,输出信息包含学号、姓名、生日。 (2)把1题中增加年龄(Age)属性,该属性只读,输出信息为:学号、姓名、年龄。 (3)把2题中定义一个构造函数,该构造函数可以包含(学号、姓名、生日)
(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总结类、对象、封装的含义...的网友还看了以下:
阅读下文,完成下题。一种新型“金属玻璃”日前在美国研制成功(1)一种新型“金属玻璃”日前在美国橡树 2020-04-06 …
下列扩散过程,属于刺激扩散的有①日本天皇下令仿效中国唐朝的教育制度,在中央设立太学,在地方设立国学 2020-07-05 …
VB总结类、对象、封装的含义(1)创建学生Student类,它包含三个属性:整型属性学号(NO)、 2020-07-26 …
生命之问:(14分)2013年,频繁发生的中小学生自杀事件不断刺痛我们的双眼:10月8日,乌鲁木齐一 2020-11-24 …
生命之问:材料一:2013年,频繁发生的中小学生自杀事件不断刺痛我们的双眼:10月8日,乌鲁木齐一学 2020-11-24 …
2013年10月23日,北京定慧东里小区内,初中生小颜放学回家后跳楼身亡。据了解,小颜放学前,增在学 2020-12-07 …
纯净的铁是一种银白色金属,在日常生活中用途非常广泛.某同学在学习铁的知识时,对“铁是黑色金属”产生质 2020-12-08 …
小说(n.)科技;工艺(n.)永远(adv.)在国外;到国外(adv.)真实地;事实上(adv.)记 2020-12-10 …
小说(n.)科技;工艺(n.)永远(adv.)在国外;到国外(adv.)真实地;事实上(adv.)记 2020-12-22 …
2009年3月2日,由共青团中央、共青团北京市宣武区委员会等共同主办的“抵制网络低俗之风”主题班会在 2021-01-08 …