- 1、本文档共7页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
实验十六:C_中命名空间和常用的系统类(修改)
实验十六:C#中命名空间和常用的系统类
【实验目的】
1.掌握命名空间的意义和使用;
2.掌握常用的字符串处理方法。
【实验准备】
复习配套教材相关章节的内容;
【实验内容】
在上次实验的项目中新建文件夹Shapes,将主类以外的shape相关类都移动的该文件夹,修改它们的命名空间为Shapes,再在主类中使用。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Shapes
{
public abstract class Shape
{
private string shapeType;
public string ShapeType
{
get { return shapeType; }
set { shapeType = value; }
}
public void DisplayInfo()
{
Console.WriteLine(当前图形类型 + shapeType);
}
public abstract void Draw();
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Shapes
{
class ShapeL : Shape
{
public ShapeL()
{
ShapeType = L形;
}
public override void Draw()
{
Console.WriteLine(|);
Console.WriteLine(|);
Console.Write(|);
Console.WriteLine(__);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Shapes
{
public class ShapeT : Shape
{
public ShapeT()
{
ShapeType = T形;
}
public override void Draw()
{
Console.WriteLine(_______);
Console.WriteLine( |);
Console.WriteLine( |);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Shapes
{
public class ShapeZ : Shape
{
public ShapeZ()
{
ShapeType = Z形;
}
public override void Draw()
{
Console.WriteLine(----);
Console.WriteLine( |);
Console.WriteLine( |);
Console.WriteLine( ----);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Shapes
{
class ShapeBlock : Shape
{
public
文档评论(0)