<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    rednight

    0x2B|~0x2B,That's not a question,Just do it.
    posts - 32, comments - 14, trackbacks - 0, articles - 0

    state pattern

    Posted on 2006-12-26 14:46 rednight 閱讀(343) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): 工作學(xué)習(xí)
    The logic to change state is only inside one method (initVesselView(…)) inside GrVessel.java.?

    if (viewType == VIEW_STOWAGE) {
    ??????????? vslView_ = new VesselStowageView(leftPoint, bow2Left, leftCenter,
    ???????????????????????????????????????????? rightCenter, shipWidth_);
    ??????? }
    ??????? else if (viewType == VIEW_SIDE) {
    ??????????? vslView_ = new VesselSideView(leftPoint, bow2Left, leftCenter,
    ????????????????????????????????????????? rightCenter, shipWidth_);
    ??????? }
    ??????? else if (viewType == VIEW_PLAN) {
    ??????????? vslView_ = new VesselPlanView(leftPoint, bow2Left, leftCenter,
    ????????????????????????????????????????? rightCenter, shipWidth_);
    ??????? }
    ??????? else {
    ??????????? throw new IllegalArgumentException(
    ??????????????? "GrVessel::initVesselView-->Invalid view type!");
    ??????? }


    We do not need to repeat this logic of changing view in many other method.
    This is the benefit of State design pattern.
    The 3 state classes here are VesselPlanView.java, VesselSideView.java and VesselStowageView.java

    Please note that in the state classes, if a method is supported by stateA and not supported by stateB.?
    Then, in stateB, the method body will throw an exception (IllegalArgumentException) to indicate that coder call the wrong method in the wrong state.

    Example, in VesselPlanView.java, public boolean addStowage(...).? This method is only meaningful to stowageView.

    public boolean addStowage(IlvManager manager, List transformList, IlvGraphic stowage, String stadBayN,
    ????????????????????????????? boolean isSelect) {
    ??????? throw new IllegalArgumentException(
    ??????????????? "GrVessel::addStowage-->be sure the vessel at stowage view!");
    ??? }


    Hence, in PlanView, the method body will throw exception.

    Just to share with you a better way to code.

    主站蜘蛛池模板: 成av免费大片黄在线观看| 亚洲一区二区三区高清在线观看| 真人无码作爱免费视频| 在线jlzzjlzz免费播放| 77777亚洲午夜久久多喷| 免费观看激色视频网站bd| 亚洲色图黄色小说| 成人无遮挡裸免费视频在线观看| 亚洲日本中文字幕天天更新| 日韩高清免费观看| 一区二区三区免费视频观看| 国产成人综合亚洲AV第一页| 久久国产精品免费网站| 亚洲欧洲高清有无| 免费看又爽又黄禁片视频1000| 亚洲av无码一区二区三区天堂| 免费人妻av无码专区| 爱丫爱丫影院在线观看免费| 亚洲国产成人私人影院| 无人在线观看完整免费版视频 | 最近2019中文免费字幕在线观看| 亚洲va久久久噜噜噜久久男同| 亚洲一级毛片免费在线观看| 亚洲精品乱码久久久久久蜜桃图片| 国产aa免费视频| 国产成人无码区免费内射一片色欲| 亚洲一区二区中文| 在线A级毛片无码免费真人| 一本到卡二卡三卡免费高| 中文字幕亚洲精品资源网| 午夜男人一级毛片免费| 两个人日本WWW免费版| 亚洲国产理论片在线播放| 免费一看一级毛片人| 免费无遮挡无码永久视频 | 666精品国产精品亚洲| 看全色黄大色大片免费久久| 最近更新免费中文字幕大全| 亚洲av午夜精品无码专区| 亚洲黄片毛片在线观看| 一级毛片成人免费看免费不卡|