Student 类
(1)字段与属性:姓名、学号、成绩
(2)构造方法:无参、有参(学号姓名2个参、3个参)
(3)方法:学习——每学习1小时,成绩+1;运动——输出谁正在运动
Student 类的题目,怎么写?
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- CSDN专家-showbo 2021-09-05 17:41关注
代码如下,其中run不知道是不是这个意思。有帮助麻烦点个采纳【本回答右上角】,谢谢~~有其他问题可以继续交流~
using System; using System.Linq; using System.Collections.Generic; namespace ConsoleApp1 { class Student { public string Name { get; set; } public string No { get; set; } public double Score { get; set; } public Student() : this(null, null, 0) { } public Student(string Name, string No) : this(Name, No, 0) { } public Student(string Name, string No, double Score) { this.No = No; this.Name = Name; this.Score = Score; } public void Learning() { this.Score += 1; } public void Run() { Console.WriteLine($"{Name}正在运动"); } } class Program { static void Main(string[] args) { var stu = new Student("小明", "111", 60); Console.WriteLine(stu.Name + "成绩:" + stu.Score); stu.Learning(); Console.WriteLine(stu.Name + "成绩:" + stu.Score); stu.Run(); Console.ReadKey(); } } }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 2无用
悬赏问题
- ¥20 使用Photon PUN2解决游戏得分同步的问题
- ¥15 微带串馈天线阵列每个阵元宽度计算
- ¥15 keil的map文件中Image component sizes各项意思
- ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
- ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
- ¥15 划分vlan后,链路不通了?
- ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
- ¥15 Vue3 大型图片数据拖动排序
- ¥15 Centos / PETGEM
- ¥15 划分vlan后不通了