首页 C#编程环境实验报告3

C#编程环境实验报告3

举报
开通vip

C#编程环境实验报告3江西理工大学软件学院 计算机类课程实验报告 课程名称:  C#程序设计教程  班    级:  11级软会(4)班 姓    名:      黄健        学    号:    11222122      江西理工大学软件学院 实验 三 实验名称 面向对象编程 实验日期 2013-4-2 实验成绩   实验目的、要求及内容 一、 实验目的: 1. 加深理解面向对象编程的概念,如类、对象、实例化等 2. 熟练掌握类的声明格式,特别是类的成员定义、构造函数、初...

C#编程环境实验报告3
江西理工大学软件学院 计算机类课程实验报告 课程名称:  C#程序 设计 领导形象设计圆作业设计ao工艺污水处理厂设计附属工程施工组织设计清扫机器人结构设计 教程  班    级:  11级软会(4)班 姓    名:      黄健        学    号:    11222122      江西理工大学软件学院 实验 三 实验名称 面向对象编程 实验日期 2013-4-2 实验成绩   实验目的、要求及内容 一、 实验目的: 1. 加深理解面向对象编程的概念,如类、对象、实例化等 2. 熟练掌握类的声明格式,特别是类的成员定义、构造函数、初始化对象等。 3. 熟练掌握方法的声明,理解并学会使用方法的参数传递、方法的重载等。 二、 实验内容: 操作实验3-1,3-2,3-3及其自己完成 快递公司问题件快递公司问题件货款处理关于圆的周长面积重点题型关于解方程组的题及答案关于南海问题 目 实验环境 地点:3421机房 OS:Wxp C#环境:1、VS2008 2、.NetFramework3.5 算法描述及实验步骤 实验3-1操作: 1) 阅读程序 2) 编辑、编译和运行程序 3) 自己完成:(1)分析静态成员total_rects和total_rect_area的值及构造函数的调用次序。 (2)将注释1和注释2的花括号去掉,运行结果将发生什么变化?为什么? 实验3-2操作: 1) 阅读程序 2) 编辑、编译和运行程序 3) 自己完成:将上述程序中class Test32中的三个方法: (1) void sortTitle(Card[] book,int[] index) (2) void sortAuthor(Card[] book,int[] index) (3) void sortTotal(Card[] book,int[] index) 改写成一个方法sort(Card[] book,int [] index)其中增加的参数method指示按什么字段排序。 重新修改、编译和运行程序,观察运行结果。 实验3-3操作: 1) 阅读程序 2) 自己完成:(1)修改Card类,增加每日食用额度不超过5000的限制功能。 (2)再次修改Card类,要求对银行卡进行操作前必须验证用户密码,并且在输入密码时屏幕上用“*”掩码显示。为简单起见,初始密码设为123456. 调试过程及实验结果 实验3-1: 实验3-2 实验3-3 心得体会 通过这次实践,我觉得我学到了很多东西,不光光是在知识层面上的,整体都有了进一步的了解,更是认识到编程的不容易,一个看似简单的程序,原来也有这么多的代码,但是那么一个复杂的代码,如果深入研究后你会发现其实各个代码之间都是有联系的,一个看上去巨大的程序实际上是由若干个函数、方法、类等组成的。以前对于那些小的程序尚能敲一敲,看得懂。对于大的程序就很容易感到束手无策。我觉得在问题面前我们应该先要冷静地分析一下,将大问题分解成一个个的小问题,再各个击破。 虽然成功地完成了程序,但是自己本身尚有许多不足之处,需要进一步的学习和巩固。不管是做什么都要有坚韧不拔的意志,在遇到困难的时候要懂得坚持,也要学会分析问题、解决问题。 同时,很多的东西,理解了,可是在实现的时候还是有很多的错误发生,在以后的练习和实践中,应该多动手,遇到问题多思考,即使 方案 气瓶 现场处置方案 .pdf气瓶 现场处置方案 .doc见习基地管理方案.doc关于群访事件的化解方案建筑工地扬尘治理专项方案下载 不是最优的也要想办法自己解决,然后和好的方案进行比较,从中找出自己的差距在哪里。 最后感谢老师在实验中对我们的指导 附 录 实验3-1: using System; using System.Collections.Generic; using System.Linq; using System.Text; class CRect { private int top, bottom, left, right; public static int total_rects = 0; public static long total_rect_area = 0; public CRect() { left = top = right = bottom = 0; total_rects++; total_rect_area += getHeight() * getWidth(); Console.WriteLine("CRect() Constructing recangle number{0}", total_rects); Console.WriteLine("Total rectangle areas is:{0}", total_rect_area); } public CRect(int x1, int y1, int x2, int y2) { left = x1; top = y1; right = x2; bottom = y2; total_rects++; total_rect_area += getHeight() * getWidth(); Console.WriteLine("CRect(int,int,int,int) Constructing rectangle number{0}", total_rects); Console.WriteLine("Total rectangle areas is:{0}", total_rect_area); } public CRect(CRect r) { left = r.left; right = r.right; top = r.top; bottom = r.bottom; total_rects++; total_rect_area += getHeight() * getWidth(); Console.WriteLine("CRect(CRect&) Constructing rectangle number{0}", total_rects); Console.WriteLine("Total rectangle areas is:{0}", total_rect_area); } public int getHeight() { return top > bottom ? top-bottom : bottom-top; } public int getWidth() { return right > left ? right-left : left-right; } public static int getTotalRects() { return total_rects; } public static long getTotalRectArea() { return total_rect_area; } } public class Test31 { public static void Main() { CRect rect1 = new CRect(1, 3, 6, 4), rect2 = new CRect(rect1); Console.WriteLine("Rectangle 2:Height:{0}", rect2.getHeight()); Console.WriteLine(",Width:{0}", rect2.getWidth()); CRect rect3 = new CRect(); Console.Write("Rectangle 2:Height:{0}", rect2.getHeight()); Console.WriteLine(",Width:{0}", rect3.getWidth()); Console.Write("total_rects={0}", CRect.total_rects); Console.WriteLine("total_rect_area={0}", CRect.total_rect_area); Console.Read(); } }           } public static int getTotalRects() { return total_rects; } public static long getTotalRectArea() { return total_rect_area; } } public class Test31 { public static void Main() { CRect rect1 = new CRect(1, 3, 6, 4), rect2 = new CRect(rect1); Console.WriteLine("Rectangle 2:Height:{0}", rect2.getHeight()); Console.WriteLine(",Width:{0}", rect2.getWidth()); CRect rect3 = new CRect(); Console.Write("Rectangle 2:Height:{0}", rect2.getHeight()); Console.WriteLine(",Width:{0}", rect3.getWidth()); Console.Write("total_rects={0}", CRect.total_rects); Console.WriteLine("total_rect_area={0}", CRect.total_rect_area); Console.Read(); } } 附 录 Console.WriteLine("Total rectangle areas is:{0}",total_rect_area); } public int getHeight() { return top>bottom?top-bottom:bottom-top;} public int getWidth() { return right>left?right-left:left-right;} public static int getTotalRects() { return total_rects;} public static long getTotalRectArea() { return total_rect_area;} } public class Test31 { public static void Main() { CRect rect1=new CRect(1,3,6,4),rect2=new CRect(rect1); Console.Write("Rectangle 2:Height:{0}",rect2.getHeight()); Console.WriteLine(",Width:{0}",rect2.getWidth()); { //注释1 CRect rect3=new CRect(); Console.Write("Rectangle 3:Height:{0}",rect3.getHeight()); Console.WriteLine(",Width:{0}",rect3.getWidth()); } //注释2 Console.Write("total_rects={0}",CRect.total_rects); Console.WriteLine(",total_rest_area={0}",CRect.total_rect_area); Console.Read(); } } } 【3-2】 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Card { private string title, author; private int total; 附 录 public Card() { title = ""; author = ""; total = 0; } public Card(string title, string author, int total) { this.title = title; this.author = author; this.total = total; } public void store(ref Card card) { title = card.title; author = card.author; total = card.total; } public void show() { Console .WriteLine ("Title:{0},author:{1},total:{2}",title,author ,total ); } public string Title { get { return title; } set { title = value; } } public string Author { get { return author; } set { author = value; } } public int Total { get { return total; } set { total = value; } } public class Test32 { public static void Main() { Test32 T=new Test32 (); Card [] books; int[] index; 附 录 int i,k; Card card=new Card (); Console .Write ("请输入需要入库图书的总数;"); string sline=Console .ReadLine (); int num=int .Parse (sline); books=new Card [num]; for (i=0;i0) { temp =index [n];index [n]=index [n+1];index [n+1]=temp ; } } } void sortAuthor(Card [] book,int[] index) { int i,j,m,n,temp; for (m=0;m0) { temp =index [n];index [n]=index [n+1];index [n+1]=temp ; } } } void sortTotal(Card [] book,int[] index) { int i,j,m,n,temp; for (m=0;mbook [j].Total) { temp =index [n];index [n]=index [n+1]; index [n+1]=temp ; } } } 附 录 } } 【3-3】 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication3 { class Card { long cardNo; decimal balance; int currentNum; static int number; decimal [] currentMoney; public Card() { currentMoney=new decimal[number]; } public Card(long No,decimal Balance) { cardNo=No; balance=Balance; currentMoney=new decimal[number]; } public void store(decimal Money,out int status) { if (currentNum==number) { status=0; return; } if(balance+Money<0) { status=-1; return; } currentMoney[currentNum]=Money; balance+=Money; currentNum++; status=1; } 附 录 } public void show() { Console .WriteLine("卡号:{0},当前余额:{1},当日发生业务次数:{2}",cardNo,balance,currentNum); for(int i=0;i
本文档为【C#编程环境实验报告3】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_105949
暂无简介~
格式:doc
大小:251KB
软件:Word
页数:20
分类:互联网
上传时间:2018-11-24
浏览量:39