皮皮学,免费搜题
登录
logo - 刷刷题
搜题
【简答题】
本程序实现如下功能:定义车辆类 Vehicle ,在类中定义字段、属性和虚拟方法;由基类 Vehicle 创建派生类 Motor 和 Truck , 在派生类中实现方法重载;在实例化类的对象并且调用类的方法。 【操作要求】 新建并保存项目:在 Visual Studio.NET 中,新建一个 Visual C# 控制台应用程序项目,名称设置为 Test2_5 , 位置设置为考生文件夹。 1. 定义基类 Vehicle: 为项目添加公有类 Vehicle ,保存在文件 Vehicle.cs 中。 2. 为基类 Vehicle 添加下列字段、属性和方法: l 私有字段 m_weight , 代表质量,数据类型为 int ; l 私有字段 m_wheels ,代表轮子数目,数据类型为 int ; l 公有属性 Weight ,用于获取和设置 m_weight 字段,包含 get 访问器和 set 访问器; l 公有属性 wheels ,用于获取和设置 m_wheels 字段,包含 get 访问器和 set 访问器,在类的构造函数中设置初始值为 4 ; l 虚拟方法 GetWheels() ,用于说明车辆轮子数目,方法返回一个字符串“ The wheels of the vehicle is x ” , 其中 x 表示说明属性 Wheels 的值; 3. 定义派生类 Motor 和 Truck , 在其中重写基类的构造函数和虚拟方法: l 从基类 Vehicle 中派生出公有类 Motor 和 Truck, 仍然保存在文件 Vehicle.cs 中; l 在类 Motor 的构造函数中,设置属性 wheels 的初始值为 2 ; l 在类 Truck 的构造函数中,设置属性 wheels 的初始值为 6 ; l 在类 Motor 中重写基类 Vehicle 的虚拟方法 GetAvailable ,方法返回一个字符串“ The wheels of the motor is x ” ,其中 x 表示属性 wheels 的值; l 在类 Truck 中重写基类 Vehicle 的虚拟方法 GetAvailable ,方法返回一个字符串“ T he wheels of the truck is x ” ,其中 x 表示属性 wheels 的值; 4. 在方法中实例化类的对象,调用方法输出车辆轮子数目: l 实例化 Vehicle 的一个对象 Vehicle ,调用类的方法 GetAvailable (),并输出方法返回的字符串; l 实例化 Motor 的一个对象 Motor ,调用类的方法 GetAvailable (),并输出方法返回的字符串; l 实例化 Truck 的一个对象 Truck ,调用类的方法 GetAvailable (),并输出方法返回的字符串; l 输出文本 “按回车键结束”,读取回车键结束程序。 5. 程序设计完成后进行编译,生成项目的 EXE 可执行文件。 【执行结果】 运行程序打开命令行窗口,输出车辆轮子数目,如图 2-5 所示。
手机使用
分享
复制链接
新浪微博
分享QQ
微信扫一扫
微信内点击右上角“…”即可分享
反馈
参考答案:
举一反三
【单选题】Crosby's recent study of American historical demography is blithely based on the reconstitution of the records of single parishes, a method that often excludes migrants. Moreover, it is troublesome fo...
A.
summarizing the findings of a study
B.
placing new research within its historical context
C.
evaluating the methodology of a historian
D.
comparing various demographical techniques
E.
establishing categories
【单选题】朱红:红松鼠在糖松的树皮上打洞以吸取树液。既然糖松的树液主要是由水和少量的糖组成,大致可以确定红松鼠是为了寻找水或糖。水在松树生长的地方很容易通过其他方式获得。因此,红松鼠不会是因为找水而费力地打洞,它们可能是在寻找糖。 林娜:一定不是找糖而是找其他什么东西,因为糖松树液中糖的浓度太低了,红松鼠必须饮用大量的树液才能获得一点点糖。 由此可以推出,朱红的论证是通过以下哪种方式展开的?
A.
陈述了一个一般规律,该论证是运用这个规律的一个实例
B.
对更大范围的一部分可观察行为做出了描述
C.
根据被清楚理解的现象和未被解释的现象间的相似性进行类推
D.
排除对一个被观察现象的一种解释,得出了另一种可能的解释
【单选题】复合树脂充填V类洞,以下设计正确的是
A.
小缺损及中等缺损设计应尽量保守
B.
仅在釉质壁做斜面
C.
范围大的缺损应预备固位形
D.
固位形的设计可为固位沟
E.
以上都正确
【简答题】What does the recent study say? The recent study says that 1.______ people today are 2.______ worldwide.
【单选题】Multivitamins urged for all pregnant women A recent study in Tanzania found that when pregnant women took vitamins every day,fewer babies were born too small.Babies that weigh less than two and one-ha...
A.
20,000,000.
B.
18,000,000.
C.
2,000,000.
D.
38,000,000.
【单选题】朱红:红松鼠在糖松的树皮上打洞以吸取树液。既然糖松的树液主要是由水和少量的糖组成,大致可以确定红松鼠是为了寻找水或糖。水在松树生长的地方很容易通过其他方式获得。因此,红松鼠不会是因为找水而费力地打洞,它们可能是在寻找糖。 林娜:一定不是找糖而是找其他什么东西,因为糖松树液中糖的浓度太低了。红松鼠必须饮用大量的树液才能获得一点点糖。 朱红的论证是通过以下哪种方式展开的?( )
A.
陈述了一个一般规律,该论证是运用这个规律的一个实例
B.
对更大范围的一部分可观察行为做出了描述
C.
根据被清楚理解的现象和未被解释的现象间的相似性进行类推
D.
排除对一个被观察现象的一种解释,得出了另一种可能的解释
【单选题】Crosby's recent study of American historical demography is blithely based on the reconstitution of the records of single parishes, a method that often excludes migrants. Moreover, it is troublesome fo...
A.
summarizing the findings of a study
B.
placing new research within its historical context
C.
evaluating the methodology of a historian
D.
comparing various demographical techniques
E.
establishing categories
【简答题】A recent study confirmed the interconnectivity of different species, which many havealways known about. 查看材料
【单选题】The recent study has shown that people's attitudes towards protecting the environment are not with their behavior in daily life.
A.
consistent
B.
reliable
C.
satisfied
D.
enthusiastic
【单选题】Multivitamins Urged for All Pregnant Women A recent study in Tanzania found that when pregnant women took vitamins every day, fewer babies were born too small. Babies that weigh less than two and one-...
A.
20,000,000.
B.
18,000,000.
C.
2,000,000.
D.
38,000,000.
相关题目:
参考解析:
知识点:
题目纠错 0
发布
创建自己的小题库 - 刷刷题