×

Loading...
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。

Guys, I think we should implement (叶雨)'s great idea, not only explain the Concept of building a WashRoom, but make it as a GREATE OPEN SOURCE project, ok? let's do it.. I just used C# Interface to briefly implement the WashRoom..

本文发表在 rolia.net 枫下论坛using System;
using System.Collections.Generic;
using System.Text;

namespace BuildingWashroom
{
public interface IDoor
{
// if the previous user Lock() the door, the IsLocked would be TRUE
// otherwise, the IsLocked would be FALSE
bool IsLocked { get; }
// if the door is locked, then the Open() would return a FALSE value
bool Open();
// Just close the door, so if two or more people want to come in, when the
// Lock() is not excuted, then, let them come in
void Close();
// Lock the door, so that no more people could come in
void Lock();
// Unlock the door, so that u can get out
void UnLock();
}

public interface IToiletBout
{
// sure, the Toilet should has a door, isn't it?
// if the door is locked, that means someone is using the toilet
// this would be very usefully when the IGenericWashroom.GetNextAvailableToiletBout()
// try to find out the next Available ToiletBout
IDoor Door { get; set; }
// i don't want to say anymore to this, hehe
void LoadShit(object shit);
// after ur working, u have to flush it
void Flush();
}

public interface IPeePool
{
// if someone is using, set it to true, so the IManWashroom.GetNextAvailablePeePool()
// could eazily find out the next Available PeePool
bool IsUsing { get; set;}
// just load
void LoadPee(object pee);
// U have to flush it
void Flush();
}

public interface IGenericWashroom
{
IDoor Door { get; set; }
IToiletBout[] ToiletBouts { get; set; }
IToiletBout GetNextAvailableToiletBout();
}

public interface IManWashroom : IGenericWashroom
{
IPeePool[] PeePools { get; set; }
IPeePool GetNextAvailablePeePool();
}

// A man shoud do three things in a WashRoom
public interface IMan
{
void ToPee(IPeePool peePool, object stuff);
void ToPee(IToiletBout toiletBout, object stuff);
void ToMakeShit(IToiletBout toiletBout, object stuff);
}



// Use it to test
public class TestIt
{
static void Main(string[] args)
{
// now suppose we already had everything we want...
IMan aMan;
IManWashroom aManWashRoom;

// now we have to check if there any Available Toilet Bout in this WashRoom?
IToiletBout toiletBout;
if ((toiletBout = aManWashRoom.GetNextAvailableToiletBout()) != null)
{
// Ok, we now has a Available Toilet Bout, good, en...
// OPEN the door, CLOSE the door, and LOCK the door so that nobody can bother him
toiletBout.Door.Open();
toiletBout.Door.Close();
toiletBout.Door.Lock();
// haha, now we can start making our shit..
aMan.ToMakeShit(toiletBout, new object());
// now it's time to FLUSH
toiletBout.Flush();
// now, unlock the door, open the door and get out, so that next guy could come in
toiletBout.Door.UnLock();
toiletBout.Door.Open();
}


}
}
}更多精彩文章及讨论,请光临枫下论坛 rolia.net
Report

Replies, comments and Discussions:

  • 工作学习 / 学科技术讨论 / Guys, I think we should implement (叶雨)'s great idea, not only explain the Concept of building a WashRoom, but make it as a GREATE OPEN SOURCE project, ok? let's do it.. I just used C# Interface to briefly implement the WashRoom..
    本文发表在 rolia.net 枫下论坛using System;
    using System.Collections.Generic;
    using System.Text;

    namespace BuildingWashroom
    {
    public interface IDoor
    {
    // if the previous user Lock() the door, the IsLocked would be TRUE
    // otherwise, the IsLocked would be FALSE
    bool IsLocked { get; }
    // if the door is locked, then the Open() would return a FALSE value
    bool Open();
    // Just close the door, so if two or more people want to come in, when the
    // Lock() is not excuted, then, let them come in
    void Close();
    // Lock the door, so that no more people could come in
    void Lock();
    // Unlock the door, so that u can get out
    void UnLock();
    }

    public interface IToiletBout
    {
    // sure, the Toilet should has a door, isn't it?
    // if the door is locked, that means someone is using the toilet
    // this would be very usefully when the IGenericWashroom.GetNextAvailableToiletBout()
    // try to find out the next Available ToiletBout
    IDoor Door { get; set; }
    // i don't want to say anymore to this, hehe
    void LoadShit(object shit);
    // after ur working, u have to flush it
    void Flush();
    }

    public interface IPeePool
    {
    // if someone is using, set it to true, so the IManWashroom.GetNextAvailablePeePool()
    // could eazily find out the next Available PeePool
    bool IsUsing { get; set;}
    // just load
    void LoadPee(object pee);
    // U have to flush it
    void Flush();
    }

    public interface IGenericWashroom
    {
    IDoor Door { get; set; }
    IToiletBout[] ToiletBouts { get; set; }
    IToiletBout GetNextAvailableToiletBout();
    }

    public interface IManWashroom : IGenericWashroom
    {
    IPeePool[] PeePools { get; set; }
    IPeePool GetNextAvailablePeePool();
    }

    // A man shoud do three things in a WashRoom
    public interface IMan
    {
    void ToPee(IPeePool peePool, object stuff);
    void ToPee(IToiletBout toiletBout, object stuff);
    void ToMakeShit(IToiletBout toiletBout, object stuff);
    }



    // Use it to test
    public class TestIt
    {
    static void Main(string[] args)
    {
    // now suppose we already had everything we want...
    IMan aMan;
    IManWashroom aManWashRoom;

    // now we have to check if there any Available Toilet Bout in this WashRoom?
    IToiletBout toiletBout;
    if ((toiletBout = aManWashRoom.GetNextAvailableToiletBout()) != null)
    {
    // Ok, we now has a Available Toilet Bout, good, en...
    // OPEN the door, CLOSE the door, and LOCK the door so that nobody can bother him
    toiletBout.Door.Open();
    toiletBout.Door.Close();
    toiletBout.Door.Lock();
    // haha, now we can start making our shit..
    aMan.ToMakeShit(toiletBout, new object());
    // now it's time to FLUSH
    toiletBout.Flush();
    // now, unlock the door, open the door and get out, so that next guy could come in
    toiletBout.Door.UnLock();
    toiletBout.Door.Open();
    }


    }
    }
    }更多精彩文章及讨论,请光临枫下论坛 rolia.net
    • 好, 做好后无偿赠给Rolia, 这样, 我们就名正言顺的有了网上公共厕所了.
    • 很好很好!我本來的目的就是抛磚引玉,希望大家在活潑的交流過程中相互學習和提高。謝謝大貓。
      • we should define the interface and abstract class first, then someone else could implement some concrete class, public these classes to some Web Services..
    • 建议先写好设计图。不然,造出茅坑还不能用:)