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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

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

实验5C#程序设计.docx

1、实验5C#程序设计实验报告一姓 名专业课程名称一、 实验名称:实验1二、 实验目的:掌握使用命令行开发简单的C#应用程序掌握使用Visual Studio编写控制台应用程序掌握Visual Studio环境下程序的跟踪调试了解Visual Studio在线帮助的使用掌握应用程序命令行参数的使用三、实验内容及要求利用ADO.NET完成数据的增、删、改、查1.1 鼠标、窗口、菜单的操作1.2 用户账户的管理1.3 桌面图标的排列、设置桌面背景和屏幕保护程序1.4 设置任务栏、语言栏1.5 选择输入法、在“记事本”文件中输入各种符号2.1了解“资源管理器的使用”2.2 设置文件夹选项、查找文件或文件

2、夹2.3 文件/文件夹操作2.4 使用回收站具体要求请见大学计算机应用基础学习指导P37P48四、实验材料、工具、或软件Windows XP Professional SP3Visual Studio 2005五、实验步骤、结果(或记录)5-15-25-35-45-55-65-7课后题:1.2.六、实验过程中存在问题和解决 有个别程序函数间的衔接不是很明白!七、意见和建议八、教师评语(或成绩) 教师签字: 年 月 日备注:实验报告的命名格式为:学号-姓名-实验序号。如805052103-刘闽-实验一1.using System;using System.Collections.Generic;

3、using System.Linq;using System.Text;namespace Console_5_1 class MyMath public const double PI = 3.1415926; public static double Perimeter(double r) double p = 2 * PI * r; return p ; public static double Area(double r) double a = PI * r * r; return a; public static double Volume(double r) double v =

4、4 * PI * Math.Pow(r, 3) / 3; return v; class Program static void Main(string args) Console.Write(请输入半径:); double r = double.Parse(Console.ReadLine(); Console.WriteLine(圆的周长=0, MyMath.Perimeter(r); Console.WriteLine(圆的面积=0, MyMath.Area(r); Console.WriteLine(球的体积=0, MyMath.Volume(r); Console.ReadKey()

5、; 2.using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication4 public class TemperatureCelsius protected double degree; public TemperatureCelsius(double d) this.degree = d; public double ToFahrenheit() return (degree * 9 / 5) + 32; class Program s

6、tatic void Main(string args) Console.Write(请输入摄氏温度:); double d = Double.Parse(Console.ReadLine(); TemperatureCelsius celsius = new TemperatureCelsius(d); Console.WriteLine(摄氏温度 = 0,华氏温度 = 1 , d, celsius.ToFahrenheit(); Console.ReadKey(); 3.using System;using System.Collections.Generic;using System.T

7、ext;namespace Console5_3 public class Person public string name; public uint age; public Person(string name, uint age) this.name = name; this.age = age; public virtual void Getinfo() Console.WriteLine(Name:0, name); Console.WriteLine(Age:0,age); public class Teacher : Person public string teacherID;

8、 public Teacher(string name, uint age, string id) : base(name, age) this.teacherID = id; public override void Getinfo() base.Getinfo(); Console.WriteLine(teacherID:0, teacherID); public class TestPersonTeacher static void Main(string args) Teacher objteacher = new Teacher(MR. YU, 40, 1990108001); ob

9、jteacher.Getinfo(); Console.ReadLine(); 4.using System;using System.Collections.Generic;using System.Text;namespace _4 public abstract class Shape protected string name; public Shape(string name) this.name = name; public abstract void show(); public abstract double area(); public class rectangle : S

10、hape protected double weight; protected double heigh; public rectangle(string name, double w, double h):base(name ) this.weight = w; this.heigh = h; public override void show() Console.WriteLine(rectangle:0,area:1, name, weight * heigh); public override double area() return weight * heigh; public cl

11、ass circle : Shape protected double radius; public circle(string name, double r) : base(name) this.radius = r; public override void show() Console .WriteLine (circle:0,area1,name ,Math .PI *radius*radius ); public override double area() return Math.PI * radius * radius; class Program static void Mai

12、n(string args) Shape s=new rectangle (小矩形,2.0,4.0),new circle (大圆,10); foreach (Shape e in s) e.show(); Console.ReadKey(); 5.using System;using System.Collections.Generic;using System.Text;namespace _5 class Program public struct Complex public int real; public int imaginary; public Complex(int real

13、, int imaginary) this.real = real; this.imaginary = imaginary; public static Complex operator +(Complex c1, Complex c2) return new Complex(c1.real + c2.real, c1.imaginary + c2.imaginary); public static Complex operator -(Complex c1, Complex c2) return new Complex(c1.real - c2.real, c1.imaginary - c2

14、.imaginary); public static Complex operator *(Complex c1, Complex c2) return new Complex(c1.real * c2.real - c1.imaginary * c2.imaginary, c1.real * c2.real + c1.imaginary * c2.imaginary); public override string ToString() return (string.Format(0+1i, real, imaginary); class testComplex static void Ma

15、in(string args) Complex num1=new Complex (5,7); Complex num2=new Complex (1,2); Complex sum=num1 +num2 ; Complex sub=num1 -num2 ; Complex mul=num2 *num1 ; Console .WriteLine (第一个复数是:0,num1 ); Console .WriteLine (第二个复数是:0,num2 ); Console .WriteLine (两个复数之和:0,sum ); Console .WriteLine (两个复数之差:0,sub );

16、 Console .WriteLine (两个复数之积:0,mul ); Console.ReadKey(); 6.namespace sy_5_6 public interface ICDPlayer void Play(); void Stop(); void PreviousTrack(); void NextTrack(); int CurrentTrack get; public class CDPlayer : ICDPlayer private int currentTrack = 0; public void Play() Console.WriteLine(启动CD.); p

17、ublic void Stop() Console.WriteLine(停止CD.); public void PreviousTrack() Console.WriteLine(前一个音轨.); if (currentTrack = 1) currentTrack-; public void NextTrack() Console.WriteLine(后一个音轨.); currentTrack+; public int CurrentTrack get return currentTrack; class TestCDPlayer static void Main(string args)

18、CDPlayer myCD = new CDPlayer(); myCD.Play(); Console.WriteLine(myCD.CurrentTrack=0, myCD.CurrentTrack); myCD.NextTrack(); myCD.NextTrack(); Console.WriteLine(myCD.CurrentTrack=0, myCD.CurrentTrack); ICDPlayer myICD = (ICDPlayer)myCD; myICD.PreviousTrack(); Console.WriteLine(myICD.CurrentTrack=0, myI

19、CD.CurrentTrack); myICD.Stop(); Console.ReadKey(); 7.using System;using System.Collections;using System.Linq;using System.Text;namespace _5_7 class Program public class NameListEventArgs : EventArgs public string Name get; set; public int Count get; set; public NameListEventArgs(string name, int cou

20、nt) Name = name; Count = count; public delegate void NameListEventHandler(object source, NameListEventArgs args); public class NameList ArrayList list; public event NameListEventHandler nameListEvent; public NameList() list = new ArrayList(); public void Add(string Name) list.Add(Name); if (nameList

21、Event != null) nameListEvent(this, new NameListEventArgs(Name, list.Count); public class EventDemo public static void Method1(object source, NameListEventArgs args) Console.WriteLine(列表中增加了项目:0, args.Name); public static void Method2(object source, NameListEventArgs args) Console.WriteLine(列表中的项目数:0

22、, args.Count); static void Main(string args) NameList n1 = new NameList(); n1.nameListEvent += new NameListEventHandler(EventDemo.Method1); n1.nameListEvent += new NameListEventHandler(EventDemo.Method2); n1.Add(张三); n1.Add(李四); n1.Add(王五); Console.ReadLine(); 课后题1.using System;namespace _5 class Pr

23、ogram public abstract class sharp protected string name; public sharp(string name) this.name = name; public abstract void area(); public abstract void perimeter(); public class circle : sharp public double radius; public circle(string name, double r) : base(name) this.radius = r; public override voi

24、d area() Console.WriteLine(circle:0,area:1, name, Math.PI * radius * radius); public override void perimeter() Console.WriteLine(circle:0,perimeter:1, name, 2 * Math.PI * radius); public class triangle : sharp public double side1, side2, side3,p,h; public triangle(string name, double a, double b,dou

25、ble c) : base(name) this.side1 = a; this.side2 = b; this.side3 = c; public override void area() p=side1+side2+side3; h=p/2; Console.WriteLine(triangle:0,area:1, name, Math.Sqrt(h * (h - side1)*(h - side2)*(h - side3); public override void perimeter() Console.WriteLine(triangle:0,perimeter:1, name, s

26、ide1 + side2 + side3); public class quadrangle : sharp public double weight; public double height; public quadrangle(string name, double w, double h) : base(name) this.weight = w; this.height = h; public override void area() Console.WriteLine(quadrangle:0,area:1, name, weight * height); public overr

27、ide void perimeter() Console.WriteLine(quadrangle:0,perimeter:1, name, 2 * (height + weight); static void Main(string args) sharp s = new circle(大圆, 3.5), new triangle(小三角, 4.0, 6.0,5.0), new quadrangle(矩形, 4.0, 8.0) ; foreach (sharp e in s) e.area(); e.perimeter(); Console.ReadKey(); 2.using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace _2 class Program public class doubop public int x; public int y; public doubop(int x, int y) this.x = x; this.y = y; public static doubop operator +(doubop x1) x1.x+; x1.y+; retur

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

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