ImageVerifierCode 换一换
格式:DOCX , 页数:20 ,大小:19.37KB ,
资源ID:3593611      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/3593611.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(C#基础编程设计实验报告.docx)为本站会员(b****4)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

C#基础编程设计实验报告.docx

1、C#基础编程设计实验报告C#基础编程设计实验报告 一、实验目的 1、熟悉VisualStudio.NET开发环境。 2、掌握C#应用程序的基本操作过程。 3、掌握C#的数据类型,运算符以及表达式的使用。 4、掌握分支和循环语句的使用方法。 5、掌握一维数组,二维数组及数组型数组的使用。 二、实验要求 (1)编写程序要规范、正确,上机调试过程和结果要有记录(2)做完实验后给出本实验的实验报告。 三、实验设备、环境 安装有VisualStudio.NET软件。 四、实验步骤 1、分析题意。 2、根据题目要求,新建项目。 3、编写并输入相关的程序代码。 5、运行与调试项目。 6、保存项目。 五、实验

2、内容 1、编写一个简单的控制台应用程序,打印一行文字(如你的姓名)。 usingSystem;usingSystem.Collections.Generic; usingSystem.Linq;usingSystem.Text; namespaceone.first classProgram staticvoidMain(stringargs) System.Console.WriteLine(“我叫王蕾!”); 2、编写一个简单的Windows应用程序,在窗体Load事件中书写代码,标签中显示你的姓名。 usingSystem;usingSystem.Collections.Generic;

3、usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text; usingSystem.Windows.Forms; namespaceone.second publicpartialclassForm1:Form publicForm1() InitializeComponent(); privatevoidForm1_Load(objectsender,EventArgse) this.Text=“Windows程序”; LabellblShow=newLa

4、bel(); lblShow.Location=newPoint(20,30); lblShow.AutoSize=true; lblShow.Text=“王蕾!”; this.Controls.Add(lblShow); 3、编写一个一个程序,用来判断输入的是大写字母,小写字母,数字还是其他的字符。 usingSystem;usingSystem.Collections.Generic;usingSystem.Text; namespaceone.third classProgram staticvoidMain(stringargs) Console.WriteLine(“请输入一个字符:

5、”); charc=Convert.ToChar(Console.ReadLine(); if(c=“a”&c=“A”&c=0&maj)/判断i下标的数是否大于j下标的数 aj+1=aj;/如果i下标大于j把j往后移一个位 j-; aj+1=m;/当不大于j的时候就把M的值放到i下标下面j+1是为了下标减到最前时考虑-1+1还是下标的最前面 Console.WriteLine(“排序后,数组顺序为:”); show(a); voidshow(inta) inti; for(i=0;istuk.sumScore)k=j; if(k!=i) Studenttemp; temp=stuk; stuk

6、=stui; stui=temp; /显示单科成绩的最高分 publicintHighScore(intk) intp=0; if(k=0) for(inti=1;istup.math)p=i; elseif(k=1) for(inti=1;istup.chinese)p=i; else for(inti=1;istup.chinese)p=i; returnp; /显示不及格名单 publicstring BuhgName(intk) stringname=“; if(k=0) for(inti=0;i90)&(stui.chinese90)&(stui.math90)&(stui.engl

7、ish=100) sumC1+; elseif(80=stui.english)&(stui.english90) sumC2+; elseif(70=stui.english)&(stui.english80) sumC3+; elseif(60=stui.english)&(stui.english70) sumC4+; else sumC5+; per1=sumC1/snums; per2=sumC2/snums; per3=sumC3/snums; per4=sumC4/snums; per5=sumC5/snums; returnstring.Format(“数学成绩百分比:”+”n

8、”+”90100:”+per1+” 8090:”+per2+” 8070:”+per3+” 7060:”+per4+” 60以下的:”+per5); From窗体代码: usingSystem;usingSystem.Collections.Generic; usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;namespaceTest2_6 publicpartialclassForm1:Form publicForm1() Ini

9、tializeComponent(); publicStudentListsl=newStudentList(); privatevoidbtnAdd_Click(objectsender,EventArgse) Students=newStudent(); s.stuNo=txtStuNo.Text; s.name=txtName.Text; s.chinese=Convert.ToDouble(txtChina.Text); s.math=Convert.ToDouble(txtMath.Text); s.english=Convert.ToDouble(txtEng.Text); sl.

10、addstu(s); MessageBox.Show(“添加成功”); privatevoidbtnSearch_Click(objectsender,EventArgse) intpos=sl.searchstu(this.textBox1.Text); if(pos!=-1) label7.Text=this.textBox1.Text+”的总成绩:”+sl.stupos.sumScore; elseMessageBox.Show(“不存在这个人!”); privatevoidbtnFinish_Click(objectsender,EventArgse) label7.Text=“前3名

11、:”+”n”; for(inti=0;i3;i+) sl.ProThree(); label7.Text+=sl.stui.name+”n”; label7.Text+=sl.getHL()+”n”; label7.Text+=Convert.ToString(sl.SumScore()+”n”; label7.Text+=sl.PerC()+”n”; label7.Text+=sl.PerM()+”n”; label7.Text+=sl.PerE()+”n”; 六、实验体会(遇到问题及解决办法,编程后的心得体会) 通过本次实验,我掌握了类的定义与使用;掌握了类的数据成员,属性的定义和使用;掌

12、握了方法的定义,调用和重载以及方法参数的传递以及构造函数的定义和使用。值得注意的是:本次实验中return的使用以及所在的位置,类型转换时也经常用到 实验项目名称: 继承与多态 实验学时: 6 同组学生姓名: 实验地点: 1318 实验日期: 11月16日-11月30日实验成绩: 批改教师: 批改时间: 实验3 继承与多态 一、实验目的、要求 (1)掌握类的继承性与多态性;(2)掌握虚方法的定义以及如何使用虚方法实现多态;(3)掌握抽象类的定义以及如何使用抽象方法实现多态;二、实验要求 (1)编写程序要规范、正确,上机调试过程和结果要有记录;(2)做完实验后给出本实验的实验报告。 三、实验设备

13、、环境 安装有VisualStudio.NET软件。 四、实验步骤 1、分析题意;2、根据题目要求,新建项目;3、编写并输入相关的程序代码;5、运行与调试项目;6、保存项目。 五、实验内容 1、设计一个Windows应用程序,在该程序中首先构造一个学生基本类,再分别构造小学生、中学生、大学生派生类,当输入相关数据,单击不用的按钮时,将分别创建不同的学生类对象,并输出当前学生的总人数,该学生的姓名,学生类型,平均成绩。 Student类: usingSystem;usingSystem.Collections.Generic;usingSystem.Text;namespaceTest3_1 p

14、ublicabstractclassStudent protectedstringname; protectedintage; publicstaticintnumber; publicStudent(stringname,intage) this.name=name; this.age=age; number+; publicstringName getreturnname; publicabstractdoubleAverage(); publicclassPupil:Student protecteddoublechinese; protecteddoublemath; publicPu

15、pil(stringname,intage,doublechinese,doublemath) :base(name,age) this.chinese=chinese; this.math=math; publicoverridedoubleAverage() return(chinese+math)/2; publicclassMiddle:Student protecteddoublechinese; protecteddoublemath; protecteddoubleenglish; publicMiddle(stringname,intage,double chinese,dou

16、blemath,doubleenglish) :base(name,age) this.chinese=chinese; this.math=math; this.english=english; publicoverridedoubleAverage() return(chinese+math+english)/3; publicclassCollege:Student protecteddoublerequired; protecteddoubleelective; publicCollege(stringname,intage,doublerequired,doubleelective)

17、 :base(name,age) this.required=required; this.elective=elective; publicoverridedoubleAverage() return(required+elective)/2; Form窗体内的代码: usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;namespaceTest3_1 publicpa

18、rtialclassForm1:Form publicForm1() InitializeComponent(); privatevoidbtnSmall_Click(objectsender,EventArgse) Pupilp=newPupil(txtName.Text,Convert.ToInt32(txtAge.Text),Convert.ToDouble(txtChinese.Text),Convert.ToDouble(txtMath.Text); lblShow.Text+=“总人数:”+Convert.ToString(Student.number)+”,”+”姓名:”+p.N

19、ame+”,”+”小学生”+”,”+”平均成绩为:”+p.Average()+”n”; privatevoidbtnMiddle_Click(objectsender,EventArgse) Middlem=newMiddle(txtName.Text,Convert.ToInt32(txtAge.Text),Convert.ToDouble(txtChinese.Text),Convert.ToDouble(txtMath.Text),Convert.ToDouble(TxtEnglish.Text); lblShow.Text+=“总人数:”+Convert.ToString(Studen

20、t.number)+”,”+”姓名:”+m.Name+ “,”+”中学生”+”,”+”平均成绩为:”+m.Average()+”n”; privatevoidbtnBig_Click(objectsender,EventArgse) Collegec=newCollege(txtName.Text,Convert.ToInt32(txtAge.Text),Convert.ToDouble(txtChinese.Text),Convert.ToDouble(txtMath.Text); lblShow.Text+=“总人数:”+Convert.ToString(Student.number)+”

21、,”+”姓名:”+c.Name+”,”+”大学生”+”,”+”平均成绩为:”+c.Average()+”n”; 2、设计一个Windows应用程序,在该程序中定义平面图形抽象类和派生类圆,矩形和三角形。 Figure类代码: usingSystem;usingSystem.Collections.Generic;usingSystem.Text;namespaceTest3_2 publicabstractclassFigure publicabstractdoubleArea(); publicclassCircle:Figure doubleradius; publicCircle(dou

22、bler) radius=r; publicoverridedoubleArea() returnradius*radius*3.14; publicclassJUxing:Figure doublechang; doublekuan; publicJUxing(doublec,doublek) this.chang=c; this.kuan=k; publicoverridedoubleArea() returnchang*kuan; publicclassSan:Figure doublebian; doubleheigth; publicSan(doubleb,doubleh) this

23、.bian=b; this.heigth=h; publicoverridedoubleArea() returnbian*heigth/2; Form窗体代码: usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;namespaceTest3_2 publicpartialclassForm1:Form publicForm1() Initial

24、izeComponent(); privatevoidbtnCircle_Click(objectsender,EventArgse) Circlec=new Circle(Convert.ToInt32(TxtChang.Text); lblShow.Text=“圆的面积为:”+c.Area(); privatevoidbtnJu_Click(objectsender,EventArgse) JUxingj=newJUxing(Convert.ToInt32(TxtChang.Text),Convert.ToInt32(TxtHigh.Text); lblShow.Text=“矩形的面积为:

25、”+j.Area(); privatevoidbtnSan_Click(objectsender,EventArgse) Sans=newSan(Convert.ToInt32(TxtChang.Text),Convert.ToInt32(TxtHigh.Text); lblShow.Text=“三角形的面积为:”+s.Area(); 3、定义一个Person类,包含姓名字段和一个方法,早上8:30学生开始上课,教师开始讲课。分别用new关键字,虚方法,抽象类实现多态性。 New关键字: usingSystem;usingSystem.Collections.Generic;usingSyst

26、em.Text; namespacethird.three classProgram staticvoidMain(stringargs) Students=newStudent(“学生”); Teachert=newTeacher(“教师”); Console.WriteLine(s.name+s.work(); Console.WriteLine(t.name+t.work(); Console.ReadLine(); publicclassPerson publicstringname; publicinterfacemethod stringwork(); publicclassStu

27、dent:Person publicStudent(stringname) this.name=name; publicstringwork() return”早上8:30开始上课”; publicclassTeacher:Person publicTeacher(stringname) this.name=name; publicstringwork() return”开始讲课”; 虚方法: usingSystem; usingSystem.Collections.Generic;usingSystem.Text; namespacethird.three.two classProgram

28、staticvoidMain(stringargs) Students=newStudent(“张三”,”学生”); PersonWork(s); Teachert=newTeacher(“李斯”,”教师”); PersonWork(t); privatestaticvoidPersonWork(PersonPerson) Console.WriteLine(Person.Work(); publicclassPerson publicstringname; publicPerson(stringname) this.name=name; publicvirtualstringWork() returnstring.Format(“Person0:早上8:30开始”,name); publicclassStudent:Person privatestringtype; publicStudent(stringname,stringtype) :base(name) this.type=type; publicoverridestringWork() returnstring.Format(“Person0:早上8:30开始上课”,name); publicclassTeacher:Person privatestringtype;

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1