using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Cat
{
static int CatNum = 0;
int Num=0 ;
private string name;
public void setCat(string str)
{
CatNum++;
Num = CatNum;
name = str;
}
public void HowManyCats()
{ Console.Write("这是{0},", name);
Console.Write("我养的第{0}只猫,",Num);
Console.WriteLine("当前共有{0}只猫", CatNum);
}
}
class Program
{
static void Main()
{
Cat myCat1 = new Cat();
Cat myCat2 = new Cat();
myCat1.setCat("小白");
myCat1.HowManyCats();
myCat2.setCat("小黑");
myCat2.HowManyCats();
myCat1.HowManyCats();
Console.ReadKey();
}
}
}
static(静态)