网站大量收购独家精品文档,联系QQ:2885784924

c#课程设计作业.doc

  1. 1、本文档共10页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
C#程序设计 -11 设有一个描述坐标点的clsPoint类,其私有 变量x和y代表一个点的x、y坐标值。编写程 序实现以下功能:利用构造函数传递参数, 并设其默认参数值为60和75,利用方法 display()输出这一默认的值;利用公有方 法setPoint()将坐标值改为(100,120), 并利用方法输出修改后的坐标值。 源代码: ClsPoint.cs using System; using System.Collections.Generic; using System.Text; namespace __11 { class clsPoint { private int x; private int y; public clsPoint() { this.x = 60; this.y = 75; } public void display() { Console.WriteLine( ({0},{1}),this.x,this.y); } public void setPoint(int _x,int _y) { this.x = _x; this.y = _y; } } } Program.cs using System; using System.Collections.Generic; using System.Text; namespace __11 { class Program { static void Main(string[] args) { clsPoint CP=new clsPoint(); Console.Write(坐标默认值为:); CP.display(); CP.setPoint(100, 120); Console.Write(坐标重新设置为:); CP.display(); } } } 结果: -12 把定义平面直角坐标系上的一个点的类 clsPoint作为基类,派生出描述一条直线的 类clsLine,再派生出一个矩形类clsRect。要 求方法能求出两点间的距离、矩形的周长和 面积等。设计一个测试程序,并构造出完整 的程序。 源代码: ClsPoint.cs using System; using System.Collections.Generic; using System.Text; namespace __12 { //***************************基类 clsPoint***************************** public class clsPoint { public double x; public double y; public clsPoint() { this.x = 0; this.y = 0; } public void setPoint(double _x,double _y) { this.x = _x; this.y = _y; } public void display() { Console.Write( ({0},{1}), this.x, this.y); } } //*********************派生类 clsLine********************************* public class clsLine : clsPoint { public clsPoint Point_start; public clsPoint Point_end; public clsLine(clsPoint Point_start, clsPoint Point_end) { this.Point_start=Point_start; this.Point_end = Point_end; } public double longness() { double l; l = System.Math.Sqrt((this.Point_start.y - this.Point_end.y) * (this.Point_start.y - this.Point_end.y) + (this.Point_start.x - this.Point_end.x) * (this.Point_start.x - this.Point_end.x)); return l; } } //*********************派生类 clsRect********************************* public class clsRect : clsPoint { public clsPoint point1; public clsPoint point2=new c

文档评论(0)

汪汪队 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档