RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:9:30-18:00
你可能遇到了下面的问题
关闭右侧工具栏
My Bridge in C#
  • 作者:xiaoxiao
  • 发表时间:2020-12-23 10:52
  • 来源:未知

//MyBridgeusing System;

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

//sonclass1:FemaleManagerclass FemaleManager:Manager{ override public void KickOut() {  Console.WriteLine("Please Go Out!"); }};//sonclass2:MaleManagerclass MaleManager:Manager{ override public void KickOut() {  Console.WriteLine("Out!Shit!"); }};//-------------------------------------------------Class Manager//-------------------------------------------------Class ChatRoomclass 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//-------------------------------------------------TestAppclass 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