My Bridge in C#

类别:.NET开发 点击:0 评论:0 推荐:

//MyBridge
using System;

//-------------------------------------------------Class Manager
//parent class
abstract class Manager
{
??? //Method:KickOut
?abstract public void KickOut();
};

//sonclass1:FemaleManager
class FemaleManager:Manager
{
?override public void KickOut()
?{
??Console.WriteLine("Please Go Out!");
?}
};
//sonclass2:MaleManager
class MaleManager:Manager
{
?override public void KickOut()
?{
??Console.WriteLine("Out!Shit!");
?}
};
//-------------------------------------------------Class Manager
//-------------------------------------------------Class ChatRoom
class ChatRoom
{
?//manager to keep the room silent:Field
?private Manager chatroommanager;

?//property
?public Manager ChatRoomManager
?{
??set{ chatroommanager=value; }
?}

?//Method
??? public void KickOut()
?{
??chatroommanager.KickOut();
?}
};
//-------------------------------------------------Class ChatRoom
//-------------------------------------------------TestApp
class TestApp
{
?public static void Main(string []args)
?{
??ChatRoom chatroom = new ChatRoom();
??
??chatroom.ChatRoomManager=new FemaleManager();
??chatroom.KickOut();

??chatroom.ChatRoomManager=new MaleManager();
??chatroom.KickOut();

??while(true);
?}
};


//-------------------------------------------------TestApp

本文地址:http://com.8s8s.com/it/it44495.htm