c#?г????????????????
???????????? ???????[ 2013/9/26 13:42:55 ] ????????
??????????????????
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
///<summary>
/// ????????????????????//////////////////////////
///</summary>
interface IAnimal //??????
{
void eating();
//??????????????????????????static??abstract????
}
abstract class Bird :IAnimal //??????Bird?????IAnimal???
{
public void eating() { Console.WriteLine("????"); } //???????????????????????????÷???
abstract public void flying(); //?????????????????????????
}
class Chick : Bird //Chick?????????Bird????????
{
public int chibangnumber;
public Chick()
{
Console.WriteLine("???????С????");
chibangnumber = 2;
}
//???????????flying????????override
public override void flying()
{ Console.WriteLine("????У?"); }
};
///<summary>
/// ???γ?????????????????????????????A????????B??г?????A????C??г?????B
/// ?????е??????????????????????????????????й?????
///</summary>
abstract class A //??????A??????
{
public int x; //??????г??
public A(int m) { x = m; } //??????A???????
abstract public int fun1(); //??????fun1()????
}
abstract class B : A //??B?????????
{
public B(int m):base(1) { x = m; } //??????A???????
abstract public int fun2(); //???????????????fun2()
public abstract int px { get;set; } //???????????px???????д
public abstract int py { get; } //???????????py?????
}
class C: B //??C????????????B????????????е??????
{
int y?? z;
public C(int x1?? int y1):base(x1) //??????
{ y = x1; z = y1; }
public override int fun1() //??????fun1???
{ return x * y; }
public override int fun2() //??????fun2???
{ return x / y; }
public override int px //????????px?????
{
get
{
try { return x+10; }
catch {throw new Exception("The method or operation is not implemented."); }
}
set
{ try { x = value; }
catch { throw new Exception("The method or operation is not implemented."); }
}
}
public override int py //????????py?????
{
get
{ try { return y-10; }
catch{ throw new Exception("The method or operation is not implemented."); }
}
}
}
class Program //??????
{
static void Main(string[] args)
{
//??????
Chick ch = new Chick();
ch.eating();
ch.flying();
Console.WriteLine("????????:{0}"?? ch.chibangnumber);
//???γ????????
C c = new C(5??2); //??????c?????C
Console.WriteLine("{0}??{1}"?? c.fun1()??c.fun2());
Console.WriteLine("{0}"?? c.x);
Console.WriteLine("{0}??{1}"?? c.px??c.py); //???ó???????
}
}
}
???????н????
???????????С????
????????
????????У?
????????????2
????25??1
????5
??????

???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11