资源简介
完整的C#宠物商店小实例代码,简洁易学习,交流拍砖~

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PetsShop
{
public class Pet
{
public String name;
public String color;
public int age;
}
public class Cat : Pet
{//各个字段必须为public否则程序无法通过//
public Cat(String na String co int a)//前边必须加上public否则生成实例时报错说不包含*个参数的构造函数//
{
name = na;
color = co;
age = a;
}
///
//属性/ /
///
public String Name
{
get
{
return name;
}
set
{
name = value;
}
}
public String Color
{
get
{
return color;
}
set
{
color = value;
}
}
public int Age
{
get
{
return age;
}
set
{
age = value;
}
}
}
public class Dog : Pet
{
public Dog(String na String co int a)
{
name = na;
color = co;
age = a;
}
public String Name
{
get
{
return name;
}
set
{
name = value;
}
}
public String Color
{
get
{
return color;
}
set
{
color = value;
}
}
public int Age
{
get
{
return age;
}
set
{
age = value;
}
}
}
public class PetShop
{ //将petshop设置为的所有字段和方法设为static是为了在显示窗口时用类名调用它的字段和方法//
public static int maxlen = 100;
public static Pet[] pets = new Pet[100];//宠物店最大容纳量//
public static int count = 0;
public static int getCount()//获得当前宠物数量//
{
return count;
}
public static bool AddPet(Pet e)//添加宠物//
{
if (count < maxlen)
{
if (e is Cat)//判断类型用is//
{
pets[count++] = e;
return true;
}
else if (e is Dog)
{
pets[count++] = e;
return true;
}
else return false;//必须添加该条语句,使if else语句完整否则报告并非所有输入都返回值的错误//
}
else return false;
}
public static int Find(String na String co int a)//查询宠物//
{
int i;
Cat cc;Dog dd;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2011-09-09 16:45 PetsShop\
目录 0 2011-09-11 00:38 PetsShop\PetsShop\
文件 1332 2011-09-09 18:44 PetsShop\PetsShop.sln
文件 43008 2011-09-13 22:23 PetsShop\PetsShop.suo
目录 0 2011-09-09 18:57 PetsShop\PetsShop\bin\
目录 0 2011-09-13 14:59 PetsShop\PetsShop\bin\Debug\
目录 0 2011-09-13 14:59 PetsShop\PetsShop\bin\Debug\app.publish\
目录 0 2011-09-13 14:59 PetsShop\PetsShop\bin\Debug\app.publish\Application Files\
目录 0 2011-09-13 14:59 PetsShop\PetsShop\bin\Debug\app.publish\Application Files\PetsShop_1_0_0_2\
文件 235008 2011-09-13 14:59 PetsShop\PetsShop\bin\Debug\app.publish\Application Files\PetsShop_1_0_0_2\PetsShop.exe.deploy
文件 6615 2011-09-13 14:59 PetsShop\PetsShop\bin\Debug\app.publish\Application Files\PetsShop_1_0_0_2\PetsShop.exe.manifest
文件 5557 2011-09-13 14:59 PetsShop\PetsShop\bin\Debug\app.publish\PetsShop.application
文件 428936 2011-09-13 14:59 PetsShop\PetsShop\bin\Debug\app.publish\setup.exe
文件 1889 2011-09-13 14:59 PetsShop\PetsShop\bin\Debug\PetsShop.application
文件 235008 2011-09-13 14:59 PetsShop\PetsShop\bin\Debug\PetsShop.exe
文件 3018 2011-09-13 14:59 PetsShop\PetsShop\bin\Debug\PetsShop.exe.manifest
文件 75264 2011-09-13 14:59 PetsShop\PetsShop\bin\Debug\PetsShop.pdb
文件 1889 2011-09-13 14:59 PetsShop\PetsShop\bin\Debug\PetsShop.vshost.application
文件 11600 2011-09-13 19:02 PetsShop\PetsShop\bin\Debug\PetsShop.vshost.exe
文件 3018 2011-09-13 14:59 PetsShop\PetsShop\bin\Debug\PetsShop.vshost.exe.manifest
文件 5989 2011-09-13 14:57 PetsShop\PetsShop\Class1.cs
文件 3876 2011-09-13 14:35 PetsShop\PetsShop\Form1.cs
文件 17406 2011-09-13 14:35 PetsShop\PetsShop\Form1.Designer.cs
文件 309255 2011-09-13 14:35 PetsShop\PetsShop\Form1.resx
文件 2382 2011-09-10 23:14 PetsShop\PetsShop\Form2.cs
文件 9757 2011-09-09 19:29 PetsShop\PetsShop\Form2.Designer.cs
文件 5817 2011-09-09 19:29 PetsShop\PetsShop\Form2.resx
文件 2087 2011-09-11 00:51 PetsShop\PetsShop\Form3.cs
文件 9755 2011-09-10 23:07 PetsShop\PetsShop\Form3.Designer.cs
文件 5817 2011-09-10 23:07 PetsShop\PetsShop\Form3.resx
文件 2540 2011-09-11 00:52 PetsShop\PetsShop\Form4.cs
............此处省略37个文件信息
相关资源
- asp.net C#购物车源代码
- C#实时网络流量监听源码
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
- C#自定义控件
- 基于c#的实验室设备管理系统621530
- C# 使用ListView控件实现图片浏览器(源
- C#简单窗体聊天程序
评论
共有 条评论